...

View Full Version : document.writeln(' external html ')



MrAtheist
05-08-2009, 06:30 PM
Hello, I made a javascript something like this...



function popup(url,title){
var pop = window.open("", "p0pup",....blahblah......);
p0pup.document.open();
p0pup.document.writeln('<html><head>.......//keeps going......</body></html>');
p0pup.document.close();
}


Basically it is a popup script. My question is that is there any way to reference to an external html using document.writeln? Instead of messy html codes within document.writeln, maybe something like this?

p0pup.document.writeln('popup.html');

Thanks for any tips.

Philip M
05-08-2009, 06:43 PM
No, document.write() can only output a literal string.

document.writeln('popup.html'); outtputs the literal popup.html


All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

MrAtheist
05-08-2009, 06:49 PM
Uh I know that it won't work. I'm just wondering is there any way to do it to reference to an external html?

adios
05-08-2009, 06:58 PM
window.open already features a way to "reference to an external html" ...

window.open([url], [name], [features])

Is that what you meant?

MrAtheist
05-08-2009, 07:22 PM
so something like this?




<script language = "javascript">
function popup(url,title){
var pop = window.open("popup.html", "p0pup",....blahblah......);
p0pup.document.open();
p0pup.document.close();
p0pup.focus();
}
</script>


<input type="submit" value="submit" onClick="popup('url','title')"/>


where popup.html lives in the same directory as in index.html

However, all it pops up is a blank page...any idea why? (and...popup.html is not blank)

Eldarrion
05-08-2009, 07:28 PM
More like....



function popup(url,title){
var pop =window.open("popup.html", "p0pup",....blahblah......);
pop.focus();
}


In other words, you're trying to open p0pup while you're assigning window.open to a variable, called 'pop'.

MrAtheist
05-08-2009, 07:39 PM
AHa thanks a bunch.

I was going to report the bug just seconds ago. Now it pops up correctly.

Thanks

MrAtheist
05-08-2009, 07:53 PM
Uh but I got another question...



function popup(url,title){
var pop = window.open("popup.html", "p0pup",....blahblah......);
pop.focus();
}

See the 2 parameters 'url' and 'title'? They are going to be used later in popup.html. Is there any way to pass the parameters into popup.html?

My guess...there aint a way to do it.

Eldarrion
05-08-2009, 10:55 PM
Not sure about title... meaning not sure what you want to do with the title itself. Are we talking about calling the new window something, or do you want to alter the <title> element in the new window itself? Because I'm not sure if that can be done... url can be passed easily though... and I guess if you want to name the window itself something, you'd be doing it like so:



function popup(url,title){
var pop = window.open(url, title,....blahblah......);
pop.focus();
}


Make sure you pass url and title as strings when calling the function. I.e:



popup("popup.html","p0pup");


See how that goes for you.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum