| View previous topic :: View next topic |
| Author |
Message |
Jake Enthusiastic Coder
Joined: 15 Mar 2005 Posts: 68
|
How do you open a new pop-up window whose width is determined by the client's screen?
Currently I open a fixed width window for a 600x800 screen from a link using :-
<a href="" onClick="window.open('pu_filename','winname','width=780,height=400,left=10,right=10,resizable');return false">Click for Pop-up</a>
To make the new window almost fill the client's screen I have tried (unsuccessfully) various bits of code like :-
<a href="" onClick="window.open('pu_filename','winname','width=window.screen.width-20,height=400,left=10,top=10,resizable');return false">Click for Pop-up</a>
and have also tried adding snippets like :-
windows.document.body.clientWidth=window.screen.width-20
There is a slight complication in that the link is located in a content frame and the new pop-up containing pu_filename is itself another frameset. This may or may not be relevant.
Any ideas, folks ?
Reply with quote
|
| |
|
|
Jony Enthusiastic Coder
Joined: 18 Mar 2005 Posts: 71
|
You need something more like this
Code:
<a href="" onClick="window.open('pu_filename','winname','width='+window.screen.width-20+',height=400,left=10,top=10,resizable')
Reply with quote
|
| |
|
|
Jake Enthusiastic Coder
Joined: 15 Mar 2005 Posts: 68
|
That code does not do the trick - which is not surprising as the quote mark syntax looks incorrect to me.
Inserting an alert in the javascript to display the value of window.screen.width shows that it has the correct value.
However width=window.screen.width does not pass that screen value to width. Why?
Reply with quote
|
| |
|
|
Jony Enthusiastic Coder
Joined: 18 Mar 2005 Posts: 71
|
Because you have to pass a string to the window.open function to open the window, which is why you do have to build the string up in this case using quotes and +.
I only posted the fragment of the code that had changed, so of course you need the rest of yours to make it work. I tested the code in both IE and Firefox and it works fine.
Here's the whole line
Code:
<a href="" onClick="window.open('test.html','winname','width='+window.screen.width+',height=400,left=10,top=10,resizable');return false">Click for Pop-up</a>
Reply with quote
|
| |
|
|
|