Popup with .js file ...

They have: 12 posts

Joined: Jun 2004

I'm looking for a popup script I can use with the code located in a .js file instead of in the document.
Then I want to have a very easy way to make a link a popup link.

Any ideas?

All post that I have seen have JavaScript (first part) directly in document beetween tags ... but I want to avoid that.

Is possible to use only one popup.js file for all or several popup windows?

KarenArt's picture

She has: 354 posts

Joined: May 2001

All you need to do is have your seperate .js file (make sure you take out the "<script>" and "</script>") and link to it with
&lt;script language="javascript" src="NAME of Script.js" type="text/javascript"&gt;&lt;/script&gt;'

Is that what you were wanting?

gotta finish redesigning my sites so I can show them again.

The purpose of education is... to get more jokes!

They have: 12 posts

Joined: Jun 2004

Yes and No.. Sticking out tongue ... This code means that I will have to make as many .js files as I have links that I want to open in PopUp.

I found some code that is working Ok but its still "All in document" type...

Quote: <script language="Javascript">

</script>

whatever

With this code I can have only one .js file and I change url direct in the link..that is what I need.
I am working of making it work with external .js but if you are quicker and know better please post.

KarenArt's picture

She has: 354 posts

Joined: May 2001

All you need to do is have your script that creates your pop up window (it doesn't matter if it's in the page or an external js file) and a way to access it.

If you put the script on the page where you're using it you simply need to put

&lt;script language="Javascript"&gt;
<!--
function openpopup(popurl){
winpops=window.open(popurl,"","width=400,height=400,")
}
//-->
&lt;/script&gt;
'
in the document head.

If you want it external you create your external js file...

function openpopup(popurl){
winpops=window.open(popurl,"","width=400,height=400,")
}
'
save it as popup.js and link to it in the head section of your document using
&lt;script language="javascript" src="popup.js" type="text/javascript"&gt;&lt;/script&gt;'

Your links wouldn't change.
The important bit is you have to put something in the head section of the document whether it's the whole script or just the link to it so your page can find the javascript code. Making scripts you use a lot external is really the best way to go.

Hope that helps!

PS: the "http://www.xxx.com" part of your link is just the page you want to open in the pop up window, so there's no reason to change your links just because the script is external.

gotta finish redesigning my sites so I can show them again.

The purpose of education is... to get more jokes!

They have: 12 posts

Joined: Jun 2004

Thats it TNX!

I didnt know that either way I must have some code in head section...
Its realy good that this code is "light" one so it can be used with or without ext .js file...
I will use external.js because I will use it on several pages...

TNX for the solution... Smiling

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.