Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-23-2009, 03:10 PM   PM User | #1
rickfink
New Coder

 
Join Date: Jan 2009
Posts: 83
Thanks: 4
Thanked 0 Times in 0 Posts
rickfink is an unknown quantity at this point
open popup window with image

Hey guys,

I need to make a image open a popup window, I know how to do it like this:

function load2() {

var load = window.open('pictures','','scrollbars=no,menubar=no,height=800,width=840,resizable=yes,toolbar=no,lo cation=no,status=no');

}

then on the link just have it go to javascript:load2()

But I have a ton of different links and don't want a bunch of code in the beginning of my pages. Is there a way to make the first part just the dimensions of the new window but then when I actually make the link, I could put where I want it to link to? Like javascript:load2(pictures). or something like that?
rickfink is offline   Reply With Quote
Old 06-23-2009, 03:44 PM   PM User | #2
mike182uk
Regular Coder

 
Join Date: May 2008
Posts: 135
Thanks: 13
Thanked 10 Times in 10 Posts
mike182uk is an unknown quantity at this point
Post

one way of doing it is

firstly put all your js in an external file and include it on all the pages of site that require it, so then you can chop and change the code once, and it reflect across the site.

Code:
<script src="YOUR SCRIPT.js"></script>
then i would write a standard function that takes the link as an argument.

like so

Code:
function popUp(link){
    var window = window.open('pictures','','scrollbars=no,menubar=no,height=800,width=840,resizable=yes,toolbar=no,lo cation=no,status=no');
    var link = link

//yada yada rest of code

}
then when you want to call it

Code:
<a href="#" onlclick="popUp('/img.jpg')> my link </a>
mike182uk is offline   Reply With Quote
Old 06-23-2009, 05:05 PM   PM User | #3
rickfink
New Coder

 
Join Date: Jan 2009
Posts: 83
Thanks: 4
Thanked 0 Times in 0 Posts
rickfink is an unknown quantity at this point
Thanks that worked!

Last edited by rickfink; 06-23-2009 at 05:09 PM..
rickfink is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:05 PM.


Advertisement
Log in to turn off these ads.