1.

Solve : Open in new window?

Answer»

Pls don't laugh but for the life of me I cant get this javascript to open 'http://www.websitename.com/index.htm' in a new window.
Can someone tell me what I am doing wrong or modify this code...thanks...

images[1] = "http://www.websitename.com/index.htm'>[/url]";Complete code

Code: [Select]<script language="JavaScript"><!--

//store the quotations in arrays

images = new Array(4);

images[0] = "<a href = 'http://website.com.au'><img src='http://website.com.au/random/image2.jpg' alt='More info'></a>";

images[1] = "<a href = 'http://website.com.au'><img src='http://website.com.au/random/image2.jpg' alt='More info'></a>";

images[2] = "<a href = 'http://website.com.au'><img src='http://website.com.au/random/image3.jpg' alt='More info'></a>";

images[3] = "<a href = 'http://website.com.au'><img src='http://website.com.au/random/image4.jpg' alt='More info'></a>";

index = Math.floor(Math.random() * images.length);

document.write(images[index]);

//done

// --></script><br>
There are a couple of ways you could do this. The simplest way is taking the HTML ROUTE...

Code: [Select]images[0] = "<a href = 'http://website.com.au' target='_blank'><img src='http://website.com.au/random/image2.jpg' alt='More info'></a>";

SETTING the target to _blank will cause the link to open in a new window. Now, if you want your site to be W3C-compliant, this fix will cause it to not validate because the TAG is deprecated. So, if that's an issue for you (or if you WOULD simply like to keep using JavaScript), you may want to check out this page which explains a JavaScript alternative...

http://www.webdevelopersnotes.com/tutorials/javascript/creating_opening_new_window_pop_ups_javascript.php3

I hope this helps.yes that will work ,that is the method of arrays or pointers could be used to allow the links to be opened in a new window.in the HTML code also you could use the frame tags so as to open in a new window.
----------
ragavendraQuote from: ragavendra on October 21, 2008, 05:16:58 PM

also you could use the frame tags so as to open in a new window.

Frame tags? Yeah, I'm not sure what he's going on about either. He's just another spammer as far as I can tell.if u want to open new window means we should use target='_blank'

Quote from: johnkennedy on November 03, 2008, 01:39:43 AM
if u want to open new window means we should use target='_blank'

<a href = 'URL' target='_blank'>

This has already been said.


Discussion

No Comment Found