PDA

View Full Version : New Window



viktor
06-08-2005, 05:01 AM
How can I modify following code so the link will open in a new window which width and height will be specified by me in code ?

<script type="text/javascript">
<!--

// New/No new PM button in menu

// Image to show there are new private messages
var newPM = "http://home.ripway.com/2005-5/316598/addfriend.gif";

// Image to show there are no new private messages
var noPM = "http://home.ripway.com/2005-5/316598/house.gif";

var pmLink = document.createElement("a");
var pmImg = document.createElement("img");
var pmCell = document.getElementsByTagName("td").item(2).innerHTML;

pmLink.href = "http://viktorix.hyperboards3.com/index.cgi?action=pm_view";
pmImg.border = "0";

if(pmCell.match(/you have <.+?>, (\d+) /i)){
switch(RegExp.$1){
case "0" :
pmImg.src = noPM;
pmImg.title = "You have no new private messages.";
break;
case "1" :
pmImg.src = newPM;
pmImg.title = "You have 1 new private message.";
break;
default :
pmImg.src = newPM;
pmImg.title = "You have " + RegExp.$1 + " new private messages.";
}
pmLink.appendChild(pmImg);
document.getElementsByTagName("td").item(5).appendChild(pmLink);
}

//-->
</script>


I want this link http://viktorix.hyperboards3.com/index.cgi?action=pm_view to be open in a new window.
Thanks!

jscheuer1
06-08-2005, 06:29 AM
Replace this:

pmLink.href = "http://viktorix.hyperboards3.com/index.cgi?action=pm_view";with this:
pmLink.href = "javascript:window.open('http://viktorix.hyperboards3.com/index.cgi?action=pm_view','newWin','width=500, height=300')";Change 500 and 300 to whatever you want. For more information on window.open() check out:

http://www.dynamicdrive.com/dynamicindex8/popwin.htm

also Google:

window.open javascript