...

View Full Version : Javascript openup function



ssskaya
01-17-2003, 06:33 PM
I use the following javascript to open a new window from the page.

-------------------------------
//Begin openup function
function openup(newpage, name) {
window.open(newpage, name, "width=723, height=450, scrollbars=yes, resizable=no, toolbar=no, status=no, location=no, menubar=no");
}
// END openup function
------------------------------

It all works fine.

But now I have another button in the page that I want to be opened in a new page BUT IN DIFFERENT DIMENTIONS.

How do I put two openup functions with different window dimentions without causing a conflict?

Thanks!

justame
01-17-2003, 07:11 PM
sss...
call it just a nother® function...
where ya nowww have the script like...
function openup etc...
just a go®...
function openup2 etc...


orrr...ya can do it just a like® reyn did for images by reusing the same script...only just a call® for htmls instead of jpg...



Well, that's just a matter of knowing the image's dimensions beforehand, and using that as the parameters for opening a window of the specified size.
This simple reusable function can be called by any link that passes it the image filename, and the height and width of the image, then pops out the image in a new window of approximately that size.

Somewhere in the HEAD, insert:
<script language="JavaScript">
<!--
function show(pic,h,w){
var size="height="+h+",width="+w;
var show=open(pic,'',size)}
//-->
</script>
And for example, you want to show an image 300 pixels high x 300 pixels wide. Then just call the function and pass it the correct parameters, in this order: filename.jpg,height, and width.

<a href="javascript:show('mypic.jpg',320,320)">Show me</a>

The added 20 is optional to offset for the default top and left margins of browsers.


just a goodluck® n' hopes that helps ya...
just a ps®...youd go in this order...
filename.html,height, and width

whammy
01-18-2003, 12:16 AM
just a... whoa! Hi justame! Long time no see! :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum