469,271 Members | 1,586 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

linking external javascript

1
I want to be able to bring up a pop up window in another browser using an image link. I did this when I put the script in the body. I have my external javascript file and have the call code...<script language="JavaScript" type="text/javascript" src=/scripts/openpopup.js></script>. What I can't seem to figure out is how to link it to the image on my page to bring up the new pop up. The code I used for the script in my page was this one...<a href='javascript:openPopWin("http://www.basupport.com",800,600,"resizable")'> <img src="cart32.gif border=0></a>. By just using the call I have no image and no way to "tell" it what url pop up to go to..can anyone help!!!
Thanks Stef
Oct 25 '06 #1
3 5618
hi,

i'm not sure if i understood your problem correctly. But here is, what i think, you need.

I have a folder called Trial.
In it, i have an htm file - Trial.htm, and two other folders - one called Images, and the other called Scripts.

In the Images Folder, i have an image - Image1, which should come in the popup browser window.

In the Scripts Folder i have a javascript file, which contains the code for opening up the popup.

Now here is the code in the Trial. htm file

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <script language="Javascript" type="text/Javascript" src="Scripts/Script.js"></script>
  4.     </head>
  5.     <body>
  6.         <a href="javascript:;" onClick="MM_openBrWindow('Images/Image1.gif','title','width=505,height=330')">Photo</a>
  7.     </body>
  8. </html>
In the Script.js inside the Script folder, i have the following code.

Expand|Select|Wrap|Line Numbers
  1. function MM_openBrWindow(theURL,winName,features){
  2.     window.open(theURL,winName,features);
  3. }
When i open Trial.htm using a browswer, and when i click on photo,
The popup window opens with the specified window size, and with the photo within the popup.

i hope this is what you wanted.
Oct 27 '06 #2
And again, you have called your javascript function in the anchor tags href attribute, whereas you should call the javascript function in the onClick event of the anchor tag.
Oct 27 '06 #3
Here is how i've done it:

[HTML]<div id="whatever" onclick="window.open('Your-URL-Here.html','_blank','width=999,height=555')">
<img src="Your-Image-File-Path.jpg" width=100, height=50, border="0" >
</div>[/HTML]

basically you put a div tag around the image that you want to be the link and use the onclick to call the window.open function. you can either put a URL in the first feild of window.open or an image

I want to be able to bring up a pop up window in another browser using an image link. I did this when I put the script in the body. I have my external javascript file and have the call code...<script language="JavaScript" type="text/javascript" src=/scripts/openpopup.js></script>. What I can't seem to figure out is how to link it to the image on my page to bring up the new pop up. The code I used for the script in my page was this one...<a href='javascript:openPopWin("http://www.basupport.com",800,600,"resizable")'> <img src="cart32.gif border=0></a>. By just using the call I have no image and no way to "tell" it what url pop up to go to..can anyone help!!!
Thanks Stef
Jul 26 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by George Hernandez | last post: by
3 posts views Thread by Saurabh Aggrawal | last post: by
20 posts views Thread by Steven T. Hatton | last post: by
1 post views Thread by Joannes Vermorel | last post: by
4 posts views Thread by Sanjay Kumar | last post: by
reply views Thread by Adam Clauss | last post: by
reply views Thread by dotyet | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.