...

View Full Version : how to open my daily links in a new window



mariapa
10-03-2011, 04:02 PM
I am completely a beginner at coding and really do not know much right now.

This is the day of week link rotation script which works just great:



<script type="text/javascript">
<!--
var MyEveryDayLinks = [
['Sunday', 'http://www.google.com', 'Google'],
['Monday', 'myURL', 'LinkName'],
['Tuesday', 'myURL', 'LinkName'],
['Wednesday', 'myURL', 'LinkName'],
['Thursday', 'myURL', 'LinkName'],
['Friday', 'myURL', 'LinkName'],
['Saturday', 'myURL', 'LinkName']
];
var today = new Date();
var L = today.getDay();
document.write('Today is ' + MyEveryDayLinks[L][0] + '. My daily

URLs: <a href="' + MyEveryDayLinks[L][1] + '">' +

MyEveryDayLinks[L][2] + '<\/a>.') ;
// -->
</script>

Unfortunately I can't open urls in a new window.

I would so like this to work...but don't know why i can't make it work.

I've tried something like this with no luck...any ideas?:


<a href="javascript:[window.open(' + MyEveryDayLinks[L][1] + ', 'height=200, width=200',)];">' + MyEveryDayLinks[L][2] + '<\/a>.') ;

rangana
10-03-2011, 04:25 PM
Opening URLs can be done by using target="_blank":


document.write('Today is ' + MyEveryDayLinks[L][0] + '. My daily URLs: <a href="' + MyEveryDayLinks[L][1] + '" target="_blank">' + MyEveryDayLinks[L][2] + '<\/a>.');


However, if you insist on using window.open, you can do so with:


document.write('Today is ' + MyEveryDayLinks[L][0] + '. My daily URLs: <a href="#" onclick="window.open(\''+MyEveryDayLinks[L][1]+'\',\'windowName\',\'height=200, width=200\');return false;">' + MyEveryDayLinks[L][2] + '<\/a>.');


PS: Have a look into methods in DOM like document.createElement(), document.appendChild() etc (instead of document.write()). Google for them and similar ones.

Let us know if you need further assistance.

niralsoni
10-03-2011, 04:25 PM
option 1:

<a href="http;//www.google.com" target="_blank">Google</a>

option 2:

<a href=":;" onclick="window.open('http://www.google.com','','height=200,width=200')">Google</a>

mariapa
10-03-2011, 04:51 PM
Thanks lots rangana, you have made my Day!

thanks thanks thanks:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum