Forum Moderators: open
I have a page with a series of links (100+)
That at the moment correspond to another page which has an mp3 embedded with in it.
Here is my problem, the client would like the link to appear in a new smaller browser window, essentially a
*grimice* pop up *grimice*, because I have so many of the windows to open the usual js method setting window name,
size, features etc for every link would be increase the page size to a stupid amount of kb's any way round this.
Would it be possible to open a new browser window, target="blank" and code(js.) the target foo.html to be a certain size?
thanks
Paul
function PopUpWindow(WindowName, URL) {
var width = 640;
var height = 480;window.open(URL,WindowName,'menubar=no,toolbar=no,status=no,width='+width+',height='+height+',resizable=yes,scrollbars=yes');
}
And here is how you could call it:
<a href="windowX.html" onclick="javascript:PopUpWindow('windowX', 'windowX.html'); return false;">
The first 'windowX' is not in case there is no title tag in the linked page. It is to name the window so that your calling page can refer to it. For example, if you have a window open called windowX, then the next time your user clicks the link the new page will be loaded into the same pop-up if the name is the same. But if the name is different (say windowY) then a second pop-up will pop up.
If you don't want that, and instead want the equiv functionailty of '_blank', then the WindowName argument could be the empty string "", so you could either change the way it is called, or change the function.
Clear as mud?
Just some additional information if you are really trying to find the most minimal code: The "return false" bit tells te browser to stop, and not do the "href=" part of the <a> tag. So the "href=" part of the <a> tag is just there for those (people and bots) who have javascript disabled. So if you don't want to bother catering for those, you could reduce the code to:
<a href="javascript:PopUpWindow('windowX', 'windowX.html'); ">
[edited by: ShawnR at 1:17 pm (utc) on Sep. 3, 2003]