Forum Moderators: open

Message Too Old, No Replies

opening new browser window question

         

gonky

12:03 pm on Sep 3, 2003 (gmt 0)

10+ Year Member



Hello,

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

Sinner_G

12:14 pm on Sep 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why don't you just put a JS function into the head of your page, specifying everything but the URL? You could then just call than function from the body and that would not increase your page size.

ShawnR

12:20 pm on Sep 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



[deleted... Seems I was too slow on the submit button]

[edited by: ShawnR at 12:21 pm (utc) on Sep. 3, 2003]

gonky

12:21 pm on Sep 3, 2003 (gmt 0)

10+ Year Member



thanks
I did'nt know you could do that (my js. knowledge is pretty
non existant)

Any thoughts on where I could find examples of this kind of script?

ShawnR

12:31 pm on Sep 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here is a function definition which can go in your head section between a <script type="text/javascript"> and a </script> tag

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;">

gonky

12:36 pm on Sep 3, 2003 (gmt 0)

10+ Year Member



edit//that was quick

cheers

gonky

1:01 pm on Sep 3, 2003 (gmt 0)

10+ Year Member



works a treat!

I have a querry though can I delete the first 'windowX',
I assuming this names the window if there is no title
tag in the linked page, also is it possible to use a
relative link in 'windowX.html'

('windowX', 'windowX.html'); return false;">

thanks

ShawnR

1:10 pm on Sep 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, you can use relative links.

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]

gonky

1:13 pm on Sep 3, 2003 (gmt 0)

10+ Year Member



crystal

Thanks again thats really helped me