Forum Moderators: open

Message Too Old, No Replies

Adding a scrollbar

         

bateman_ap

2:57 pm on Apr 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi, am using the following to call a popup, however what do I need to put to make it scrollable?

function popup(url,wname,w,h)
{
newwin = window.open('',wname,'width=' + w + ',height=' + h);
}

<a href='http://www.domain.com/page.htm' target="popup" onclick="popup('http://www.domain.com/page.htm', 'popup', 500, 300);">Click to popup</a>

rocknbil

3:12 pm on Apr 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



newwin = window.open('',wname,'width=' + w + ',height=' + h + ',scrollbars,resizable');

Nothing more annoying than a window that doesn't fit the monitor, you might want to add resizable too.

<a href='http://www.domain.com/page.htm' target="popup" onclick="popup('http://www.domain.com/page.htm', 'popup', 500, 300);">Click to popup</a>

You may want to do something else for the window name. If all calls to this function pass "popup" as the name, if the user doesn't close the window any new content will appear in that window. If the new window is behind the main window, The user clicks and it appears "nothing happens."

This uses a time variable to generate a unique name for every window and insures it always comes up with a new window:

function popup(url,w,h)
{
var day = new Date();
var id = day.getTime();

newwin = open(url,id,'width=' + w + ',height=' + h+',scrollbars,resizable');
}

Also you have '' in your example for the url.

bateman_ap

8:21 am on Apr 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Many thanks for that. Javascript is not my strong point!