PDA

Click to See Complete Forum and Search --> : Specifying pop-up sizes.


goldieboy
06-13-2004, 10:03 PM
What is the code to specify how big a pop-up should be and where would I type it in?

Ryan8720
06-14-2004, 08:02 AM
<rant>
Pop-ups are bad! They annoy users and can even prevent them from viewing your site if you open your entire site with a Javascript popup. Avoid them if at all possible.
</rant>

Now, here is how to do it.
The script part goes in between the <head> tags. The other part goes whereever you want the link to be (somewhere between the tags). I've bolded the part for the size of the window (in pixels).

<script type='text/javascript'>
function popUp(URL) {
id = myPopup;
eval('page' + id + ' = window.open(URL, '' + id + '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,men ubar=0,resizable=0,width=[b]100,height=100');');
}
</script>

<a href='javascript: popUp('myPage.html')'>open popup</a>

Note: there is no space between javascript: and popup, but if I leave it like that the forum turns it into a smilie face.

http://edgewebdesign.org/ryan2.gif (http://www.edgewebdesign.org)

C:\DOS
C:\DOS\RUN
RUN DOS RUN

Post Edited (Ryan8720) : 6/14/2004 4:03:19 AM GMT

3howards
06-14-2004, 04:42 PM
ryan, what's the difference between using the 'poUp' function and the 'newWindow'? i've never used the 'popUp' function before ...

axoi
06-14-2004, 06:36 PM
3howards,

Ryan created a new function called popUp which is defined in the <script> tags. I'm not sure what the newWindow function is that you're referring to. But keep in mind all this function does is open a new window and resize it. That's all. There must be a dozen ways to do it.

- Bill

Ryan8720
06-14-2004, 07:33 PM
I'm using window.open, is that what you meant? I just put the variables in the head, so you don't have a long string of javascript in the middle of the page.

http://edgewebdesign.org/ryan2.gif (http://www.edgewebdesign.org)

C:\DOS
C:\DOS\RUN
RUN DOS RUN

3howards
06-15-2004, 01:17 AM
this is what i use in the head:


[quote]

<script language="JavaScript">
<!--
function newWindow(url, w, h) {
var params

params = 'width=' + w + ', height=' + h + ', scrollbars';
myNewWindow = window.open(url, "", params);
}
// -->
</script></CODE>an then just use this for the url:


[quote]

<a href="javascript:newWindow('link.htm', 000, 000);">Link</a></CODE>not long at all and it does the job ...

Ryan8720
06-15-2004, 06:56 AM
They are basically the same. newWindow is the name of your function. I just have mine named popUp. Notice how you are still using window.open. The reason mine is longer is because I have all of the parameters set.

http://edgewebdesign.org/ryan2.gif (http://www.edgewebdesign.org)

C:\DOS
C:\DOS\RUN
RUN DOS RUN