0

I have a link inside of a page that brings up a floating window with a series of links.

<a href='javascript:void(0);' onclick='window.open("http://mylink.html","ZenPad","width=150, height=900");' target='ZenPad'><img src=http://mygraphic.png></a>

The links on the page have (the coding in the below example) however when clicked, they appear in the same window that popped up, but the window remains at the size originally set at w150 and h900 unless you grab the side and drag it. Is there a way to have the window resize to fit the dimensions of the page the link is going to in the same window? An example of my coding below.

<a href='javascript:void(0);' onclick='window.open("http://mylink.html","ZenPad","width=850, height=600");' target='ZenPad'><img src=http://myimg.png><br><font color="#34a6a7"></a>WHOCHAT</font><br><br>

edited to show my coding:

<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>ReVo Links</title>
<SCRIPT LANGUAGE="JavaScript">
function newWindow(){
var windowWidth = 850;
var windowHeight = 600;
var xPos = (screen.width/2) - (windowWidth/2);
var yPos = (screen.height/2) - (windowHeight/2);
window.open("http://mywebpage.com","ZenPad","width=" 
+ windowWidth+",height="+windowHeight +",left="+xPos+",top="+yPos);
}
</script>
<body text="#FFFFFF" bgcolor="#000000">
<center><br>
<a href='javascript:void(0);' onclick='newWindow()' target='_blank'><img src=http://mygraphiclink.png><br><font color="#34a6a7"></a>WHOCHAT</font><br><br>

(there are other links here that need to do the same thing just testing the first link to get it to work)

</body>
</html>
Robert Ettinger
  • 319
  • 1
  • 3
  • 17
  • Here is the matcing post for your question. [resize window](http://stackoverflow.com/questions/6843249/javascript-window-open-function-allowing-to-resize-the-widow-after-setting-the) – PhilSchneider Mar 03 '15 at 14:47

1 Answers1

0

Replace the onclick for a function and set target="_blank" to open a new widow:

<a href='javascript:void(0);' onclick='newWindow()' target='_blank'><img src=http://myimg.png><br><font color="#34a6a7"></a>WHOCHAT</font><br><br>

And create the function to open new window, (this will be centered in screen and with personal size):

function newWindow(){
    var windowWidth = 850;
    var windowHeight = 600;
    var xPos = (screen.width/2) - (windowWidth/2);
    var yPos = (screen.height/2) - (windowHeight/2);
    window.open("http://mylink.html","ZenPad","width=" 
    + windowWidth+",height="+windowHeight +",left="+xPos+",top="+yPos);
}
Jordi Castilla
  • 26,609
  • 8
  • 70
  • 109