SitePoint Sponsor |
|
User Tag List
Results 1 to 14 of 14
Thread: Window.open
-
Sep 5, 2007, 13:38 #1
- Join Date
- Feb 2006
- Posts
- 159
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Window.open
I've been using the following code to open new windows:
<script launguage="javascript">
function openWindow(url)
{ window.open(url,'newpage','scrollbars=no,resizable=no,width=400,height=200');
}
<html>
....
.....
<a href="javascriptpenWindow(php/newsregister.php');">Click here</a>
...
...
</html>
My question is i cant seem to get it working so i can specify the size. i.e. i want to create a function
function openWindow(url,width,height)
Can i do this? I have tried google. Sorry if the answer is obvious. I have tried a few things
-
Sep 5, 2007, 14:19 #2
- Join Date
- Jul 2005
- Location
- West Springfield, Massachusetts
- Posts
- 17,290
- Mentioned
- 198 Post(s)
- Tagged
- 3 Thread(s)
variables
Did you try something like
HTML Code:window.open(url,'newpage','scrollbars=no,resizable=no,width=' + width + ',height=' + height + ');
Big Change Coming Soon - if you want your PMs save them now!
What you need to do to prepare for our migration to Discourse
A New SitePoint Forum Experience: Our Move to Discourse
-
Sep 5, 2007, 17:02 #3
- Join Date
- Dec 2001
- Posts
- 11
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I think you just have a simple typo.
In your call to the function, the parameter needs to be quoted, and you're missing the first quote. It should be:
Code HTML4Strict:<a href="javascript:openWindow('php/newsregister.php');">Click here</a>
-
Sep 6, 2007, 11:26 #4
- Join Date
- Feb 2006
- Posts
- 159
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Sep 6, 2007, 11:29 #5
- Join Date
- Feb 2006
- Posts
- 159
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Sep 6, 2007, 13:06 #6
- Join Date
- Dec 2001
- Posts
- 11
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ahh, well in that case, try this:
Code JavaScript:function openWindow(url, width, height) { winSettings='scrollbars=no,resizable=no,width=' + width + ',height=' + height; window.open(url,'newpage',winSettings); }
Code HTML4Strict:<a href="javascript:openWindow('http://www.socsci.uci.edu', 300, 200);">Click here</a>
-
Sep 6, 2007, 13:40 #7
- Join Date
- Feb 2006
- Posts
- 159
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
fantastic! exactly what i needed it to do. Thankyou very much for your help. You've just solved something for me i've been struggling with on and off for a couple of days.
-
Sep 6, 2007, 16:47 #8
- Join Date
- Dec 2001
- Posts
- 11
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
No problem, glad I could help. happy javascripting!
-
Sep 8, 2007, 10:18 #9
- Join Date
- Feb 2006
- Posts
- 159
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
i've come across an aditional problem. I have two links which open popups. Both are different sizes. With this code if i have the small one open and click the second link it opens up inside the already open smal window and therefore doesnt show all the content as its not big enough. Is there a way around this? Can i force it to open an additional window?
-
Sep 8, 2007, 11:26 #10
- Join Date
- Jul 2005
- Location
- West Springfield, Massachusetts
- Posts
- 17,290
- Mentioned
- 198 Post(s)
- Tagged
- 3 Thread(s)
2 windows
Give them different names.
Big Change Coming Soon - if you want your PMs save them now!
What you need to do to prepare for our migration to Discourse
A New SitePoint Forum Experience: Our Move to Discourse
-
Sep 8, 2007, 11:34 #11
- Join Date
- Feb 2006
- Posts
- 159
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
to save file sizes i've tried to limit my javascript. I'm using one function for opening popups as on another page there will be 7 different popups with different sizes.
if using one function doesnt allow me to open different pages for each one can i at least force the already open page to resize rather than keep the old size?
-
Sep 8, 2007, 11:36 #12
- Join Date
- Feb 2006
- Posts
- 159
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
actually could i specify the window name in the call to the function if i rewrote the function to accommodate?
-
Sep 8, 2007, 11:47 #13
- Join Date
- Feb 2006
- Posts
- 159
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thanks for the idea Mittineague. just tried it and created a new function with an additional parameter. perfect! Thanks again
-
Sep 8, 2007, 11:53 #14
- Join Date
- Feb 2006
- Posts
- 159
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
can i also force the windows to stay in focus and not get lost behind the rest?
Bookmarks