Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-08-2009, 06:30 PM   PM User | #1
MrAtheist
New Coder

 
Join Date: Apr 2009
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
MrAtheist is an unknown quantity at this point
document.writeln(' external html ')

Hello, I made a javascript something like this...

Code:
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.
MrAtheist is offline   Reply With Quote
Old 05-08-2009, 06:43 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,036
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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.
Philip M is offline   Reply With Quote
Old 05-08-2009, 06:49 PM   PM User | #3
MrAtheist
New Coder

 
Join Date: Apr 2009
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
MrAtheist is an unknown quantity at this point
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?
MrAtheist is offline   Reply With Quote
Old 05-08-2009, 06:58 PM   PM User | #4
adios
Senior Coder

 
Join Date: Jun 2002
Posts: 1,404
Thanks: 2
Thanked 32 Times in 32 Posts
adios is on a distinguished road
window.open already features a way to "reference to an external html" ...

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

Is that what you meant?
adios is offline   Reply With Quote
Old 05-08-2009, 07:22 PM   PM User | #5
MrAtheist
New Coder

 
Join Date: Apr 2009
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
MrAtheist is an unknown quantity at this point
so something like this?

Code:
<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)

Last edited by MrAtheist; 05-08-2009 at 07:29 PM..
MrAtheist is offline   Reply With Quote
Old 05-08-2009, 07:28 PM   PM User | #6
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
More like....

Code:
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'.
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?

Last edited by Eldarrion; 05-08-2009 at 07:34 PM.. Reason: Some wording was off... guess I need more coffee.
Eldarrion is offline   Reply With Quote
Users who have thanked Eldarrion for this post:
MrAtheist (05-08-2009)
Old 05-08-2009, 07:39 PM   PM User | #7
MrAtheist
New Coder

 
Join Date: Apr 2009
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
MrAtheist is an unknown quantity at this point
AHa thanks a bunch.

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

Thanks
MrAtheist is offline   Reply With Quote
Old 05-08-2009, 07:53 PM   PM User | #8
MrAtheist
New Coder

 
Join Date: Apr 2009
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
MrAtheist is an unknown quantity at this point
Uh but I got another question...

Code:
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.
MrAtheist is offline   Reply With Quote
Old 05-08-2009, 10:55 PM   PM User | #9
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
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:

Code:
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:

Code:
popup("popup.html","p0pup");
See how that goes for you.
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?
Eldarrion is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:32 AM.


Advertisement
Log in to turn off these ads.