/    Sign up×
Community /Pin to ProfileBookmark

New to JavaScript – new window

Hi there

I am very, very new to Javascript, so this might sound like a dumb question, but….!!

I have this code for a popup window:-

<SCRIPT LANGUAGE=”JavaScript”>
<!– Begin
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width – w) / 2;
var wint = (screen.height – h) / 2;
winprops = ”height=”+h+”,width=”+w+”,top=”+wint+”,left=”+winl+”,scrollbars=”+scroll+”,resizable”
win = window.open(mypage, myname, winprops,)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
// End –>
</script>

This is activated when the user clicks on a link which relates to a plain html page. My problem is that I want to control the size of the popup, but every time I add ‘height = x’ or change the parameters, it doesn’t seem to work…

Can anyone help me to change this, or is there something I need to add tot he html file?

If possible I would like it to just size itself to the size of the page every time…

Any help would be greatly appreciated!

Cheers
geezerbird

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@CharlesApr 20.2005 — That sort of positioning thing will cause problems on the browser Opera. Just use:&lt;a href="http://www.w3.org/" onclick="window.open (this.href, 'child', 'height=300,width=200').focus(); return false"&gt;W3C&lt;/a&gt;
Copy linkTweet thisAlerts:
@Warren86Apr 20.2005 — <HTML>

<Head>

<Script Language=JavaScript>

var popWin = "";

function openwin(mypage,myname,strWidth,strHeight,isScroll){

if (popWin != ""){popWin.close()}
leftStr = (screen.width-strWidth)/2;
topStr = (screen.height-strHeight)/2;
windowProperties = "toolbar=no,menubar=no,scrollbars="+isScroll+",stausbar=no,height="+strHeight+",width="+strWidth+",left="+leftStr+",top="+topStr+"";
popWin = window.open(mypage,myname,windowProperties);
}


</Script>

</Head>

<Body>

<a href=# onclick="openwin('1.html','window1','300','225','no')">Open a centered popup window</a>

</Body>

</HTML>
×

Success!

Help @geezerbird spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...