Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading inside a HTA

Status
Not open for further replies.

candrid2

Technical User
Apr 1, 2006
10
US
Hello all.

I have an HTA. What I would like to achieve is to have an input button that says 'click' (or anything really) and have it load a document, such as another webpage, a pdf, an image, or anything in the HTA window itself - is this possible?

I've tried things such as..

<input type="button" value="Open new window" onclick="window.navigate('tester.html', 'test');"> but this loads the result in a new window.

Any ideas? Sorry for the novice question.

-can
 
Try window.location.

window.location="path/to/file/to/load./xxx";



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
I get a syntax error. Most likely some fault of mine.

This is what I have:

Code:
<html>
<script> 
var gnWinCaption= "Report Viewer"; 
var gnWinWide= 800; 
var gnWinHigh= 600; 
 
function DoStartup() {  // called from BODY ONLOAD  
        SetWindowSize( gnWinWide, gnWinHigh ); // app init stuff 
        document.title=gnWinCaption; 
} 
function SetWindowSize(w,h) {  // known bug in mshtml; try/catch fixes 
        try     { window.resizeTo( w, h );}  
        catch(e){ SetWindowSize(w,h); }  //  do it until it works 
} 
</script> 
 
<!-- I like to put the U/I stuff at the bottom --> 
<!-- ***************************************** --> 
<body onLoad='DoStartup();'> 
<DIV align=right><input type=button value="restart"  
    onclick= "document.location.reload();"></DIV>
<br />
<div align=center><img src="150px-N.gif"><img src="imagesCAGC0KD5.jpg">
<br /><br />
<b>Report Viewer<br /></b>
<br />
<br />
<br />
<input type="button" value="Open new window" onclick="window.location="reports.txt";">
</body> 
</html>

By the way, I always see the responses you give people. I really appriciate the kindess and professionalism you show here.

Thank you, (and the community) for both the time and paitence.
 
"window.location="reports.txt";"

try:

Code:
"window.location=[COLOR=white red]'[/color]reports.txt[COLOR=white red]'[/color];"

You can't have double quotes within double quotes. That just confuses the browser because it can't tell where your command is supposed to end.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
The above response does work, however, it loads a new window.

Is there anyway to specifiy.. like
Code:
_parent
?
Sorry I am not much more help, I am pretty novice.
 
window.location changes the url of the current window you are in so it loads the file into the window you are in. Do you want to preserve the contents of your original window then?

I'm not following.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
No Sir,

The goal is to have a 'user' if you will click a button (or image) and it load a file inside that same window.

As we have worked out so far, it works, it just opens the file in a new browser window instead of the HTA.
 
I think that has to do with how HTA's work. IE opens a special kind of window to run the HTA's in. Trying to change the location to something that is not the HTA application causes another window to open. Perhaps using an iframe inside the HTA may be a better choice.

I don't have Windows and IE handy to test though.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Thanks,

Ill brainstorm a lil.

Be wary of fire engines.
 
How about loading the content of the file into a hidden div and is made visible when clicked.

Code:
<div id="file1" style="disply: none;">
   ... file content ...
</div>

<img src="myImage.jpg" onClick="file1.style.diplay='block'">

-Geates

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
- Martin Golding

"There are seldom good technological solutions to behavioral problems."
- Ed Crowley, Exchange guru and technology curmudgeon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top