View Full Version : Open New Window
chopper
04-05-2008, 07:34 AM
How would I change the below code, to load the source into a window (new window) rather than the iFrame that it is doing now.
'website' has been defined earlier in the code as www.google.com, it currently works loading into iFrame.
{
document.getElementById("iframe").src = website;
}
rangana
04-05-2008, 07:43 AM
If I take this right, I see two possibilities:
1. Open it using JS window.open() (http://www.quirksmode.org/js/popup.html)
2. Why not just have something like:
<a href="http://www.google.com" target="_blank">google</a>
chopper
04-05-2008, 07:56 AM
Ragana thanks for your reply.
Long story short, the code is reading the http address from somewhere else so the href wont work.
the window.open() sounds like a good idea, but going from my previous code I cannot work out what goes where and how.
Ive posted the whole code below with comments so you can see whats going on:
//////Website Parsing
var the_url = Message; //prompt("What's the URL?","");
//assign the chararter position of the symbol to 'dash'
var dash = the_url.indexOf("-");
//alert(dash);
//get character position 2 characters after the dash variable
var domain_start = dash + 2;
///get everything after the character poistion domain_start and set to variable website
var website = the_url.substring(domain_start, the_url.length);
//if dash is equal to or more than 19 charcater position
//then put the website variable in the iframe.
if (dash >= 19)
{
document.open.window.src = website;
//alert(Message);
}
rangana
04-05-2008, 08:10 AM
Try changing this code:
document.open.window.src = website;
to:
window.open(website,'','scrollbar=no,height=500,width=400');
chopper
04-05-2008, 08:17 AM
Sir you are a genius. Thanks very much!
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.