<html> <body bgcolor="#FFFFFF"> Hello World </body> </html>
Can some HTML ( like above, created at run time ) be loaded into AHK-IE control without being written to a .HTML file ?
:roll:
<html> <body bgcolor="#FFFFFF"> Hello World </body> </html>
I don't know until trying it. And be aware that IE_LoadHTML() has length limit for HTML constrained by about:. If the HTML is long, better create an empty document by about:blank or alike and write to it the HTML.Would it work if HTML has file references relative to the working directory ?
If the HTML is long, better create an empty document by about:blank or alike and write to it the HTML.
IE_LoadURL(ie, "about:blank") ieDoc := IE_Document(ie) COM_Invoke(ieDoc,"write",html) COM_Invoke(ieDoc,"close")This also works with document objects you create:
doc := COM_CreateObject("htmlfile") COM_Invoke(doc,"write",html) COM_Invoke(doc,"close") ; ...access DOM properties here...JavaScript won't work in this case, though.
Relative paths won't work.
#SingleInstance, Force SetWorkingDir %A_ScriptDir% Gui +LastFound hWnd := WinExist() [color=red]img1[/color]=file://c://img.jpg html= ( <html> <body bgcolor="#FFFFFF"> <table width="600" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <div align="center">Hello World </div> </td> </tr> <tr> <td> <div align="center"><img src="[color=red]%Img1%[/color]" width="160" height="160"></div> </td> </tr> <tr> <td> </td> </tr> </table> <p> </p> </body> </html> ) IE_Init() iE := IE_Add(hWnd, 5, 5, 630, 460 ) IE_LoadURL(ie, "about:blank") ieDoc := IE_Document(ie) COM_Invoke(ieDoc,"write",html) COM_Invoke(ieDoc,"close") Gui,Show, w640 h480, Load HTML fm MEM Return GuiEscape: GuiClose: ExitApp
to 'fake' relative paths
results_table_header=%results_table_footer% (Ltrim <div style="text-align: left;"><big><big><span style="font-weight: bold; font-family:arial"><a href="%Master_Doc_Location%\%FileDir%\index_files.htm">%FileDir%</a></span></big></big></div> <table align="center" [color=red]width="100`%"[/color] border="0" cellspacing="2" cellpadding="2"> <tbody style="font-family:arial; font-size:14"> <tr bgcolor="%TH_c%"> <th align="left" width="150">Document</th> <th align="left" "width=90`%">Title</th> </tr> ) ;Blah blah blah search_html= ( <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1"http-equiv="content-type"> <title>Search - "%Searchterm%"</title> </head> <body style= Background="%BG_c%" alink="FF0000" link="%TXT_c%" vlink="%TXT_c%"> <div style="text-align: center;font-family:arial"><big><big><big><span style="font-weight: bold;color=%TXT_c%">Search Results<br></span></big></big></big></div> <div style="text-align: center;font-family:arial;color=%TXT_c%"><big><small>You searched for "<span style="color: rgb(255, 0, 0);font-weight: bold;">%Searchterm%</span>"</small></big><div style="text-align: center;font-family:arial;color=%TXT_c%"><big><small>in "<span style="color: rgb(255, 0, 0);font-weight: bold;">%Restriction%</span>"</small></big><br> <a href="%LibraryPath%\index_files.htm">Home</a></div><br> %results_table% </tbody> </table> </div> Search executed in %Search_Time% ms. </body> </html> )