Is there any way I can infuse this into the page itself, so the page loads to the size I want, toolbars I want etc... and I can reference it from anywhere?
I dont know dude, I just tested the code and it works perfectly as expected. You must be doing something wrong and I dont know what it is. If its opening the window, it must be calling the function. And if the function is being called, the provided window
options will be applied, given that they are in the correct format.
Harperator
Member
140 Points
329 Posts
Javascript meets asp.net
Sep 20, 2007 12:33 PM|LINK
I have a little web utility writen in asp.net/C#.
I have it running in a browser window and im happy with it.
Only problem is, I have to call the window from a specific link, to inject the javascript I need. (see code)
<span style="font-size: 10pt"><a href="javascript:void(0);" onclick="javascript:window.open('ButtinsMainPage.aspx','ButtIns','scrollbars=1, width=320,height=460')">Get Started</a><br />
Is there any way I can infuse this into the page itself, so the page loads to the size I want, toolbars I want etc... and I can reference it from anywhere?
Like the page.load method?
TIA
JavascriptChallanged
JoshStodola
Star
13736 Points
3177 Posts
Re: Javascript meets asp.net
Sep 20, 2007 02:05 PM|LINK
Yes you can. Create a file with a .js extension and put this function in it:
function openPopup(url) { var theWin = window.open(url, 'ButtIns', 'scrollbars=1,width=320,height=460'); theWin.focus(); return false; }Include the .js file in your <head> section like this:
And now you can invoke it as many times as you want from anywhere on the page. Simply pass it the URL you wish to open:
Hope this helps! Please mark the helpful post(s) as Answer.
Harperator
Member
140 Points
329 Posts
Re: Javascript meets asp.net
Sep 20, 2007 02:26 PM|LINK
that sounds great.
Can I call it recursivly, say like in the opening of the page itself?
I just want this window to open itself to the above specs, w/o having to call teh code form a link
Where and how would I do that?
TIA
Dan
JoshStodola
Star
13736 Points
3177 Posts
Re: Javascript meets asp.net
Sep 20, 2007 02:31 PM|LINK
Yes. You can do it in the onload of the body...
<body onload="openPopup('ButtinsMainPage.aspx');">
Hope this helps! Please mark the helpful post(s) as Answer.
Harperator
Member
140 Points
329 Posts
Re: Javascript meets asp.net
Sep 20, 2007 03:28 PM|LINK
Bummer!
I got all the code to compile, but the window just opens in a regular browser window.
I am using a master file, so I assume I put the .js reference there?
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<script type="text/javascript" src="java.js"></script>
<title>ButtIns</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
JoshStodola
Star
13736 Points
3177 Posts
Re: Javascript meets asp.net
Sep 20, 2007 04:15 PM|LINK
Well what kind of window did you expect it to open in?!
Harperator
Member
140 Points
329 Posts
Re: Javascript meets asp.net
Sep 20, 2007 04:25 PM|LINK
I mean it's a browser window (What I expected) just not the dementions specified.
JoshStodola
Star
13736 Points
3177 Posts
Re: Javascript meets asp.net
Sep 20, 2007 04:39 PM|LINK
I dont know dude, I just tested the code and it works perfectly as expected. You must be doing something wrong and I dont know what it is. If its opening the window, it must be calling the function. And if the function is being called, the provided window options will be applied, given that they are in the correct format.
Best Regards...
NC01
All-Star
82577 Points
15430 Posts
MVP
Re: Javascript meets asp.net
Sep 20, 2007 04:42 PM|LINK
Try setting the dimensions as width=320px,height=460px, then the window would have to be 320 pixels x 460 pixels, as that is what you are specifying!
NC...
JoshStodola
Star
13736 Points
3177 Posts
Re: Javascript meets asp.net
Sep 20, 2007 04:44 PM|LINK
Yeah, you should be specifying a unit. I just copied the code you had earlier assuming it worked as you wanted it do (you did say "Im happy with it")