Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need some javascript help...(inserting from outside source)

Status
Not open for further replies.

V1SHAL

Technical User
Joined
Jul 6, 2006
Messages
1
Location
US
Hi...

I have a script that I want to move to an outside source (i.e. remove from the xhtml coding of my webpage and link back to it). How can I alter this script and/or my html code so that I can specify which link i want this to work for and yet keept this entire code out of my xhtml.

In short, what changes can I make to make such a coding, valid...
Code:
<script src="PopMeUp_1.js" type="text/javascript"></script>

I currently have this script in my <head> section w/ the following in the body:
Code:
<a href="javascript:PopupMe1()">EMAIL UPDATES</a>


This is the script I have:
Code:
<script language="JavaScript1.2" type="text/javascript">
var ie=document.all
var dom=document.getElementById
var ns4=document.layers
var calunits=document.layers? "" : "px"
var bouncelimit
var direction="up"
var usedropin=1
function PopupMe1(){
if (!dom&&!ie&&!ns4){
window.open("searchbar.htm", "", "scrollbars=1")}else{
bouncelimit=32 //(must be divisible by 8)
crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin
crossframe=(dom)?document.getElementById("cframe") : ie? document.all.cframe : document.cframe
crossframe.src="searchbar.htm"
if(usedropin){
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
crossobj.top=scroll_top-250+calunits}
crossobj.visibility=(dom||ie)? "visible" : "show"
if(usedropin){
dropstart=setInterval("dropin()",50)}}}
function dropin(){
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
if (parseInt(crossobj.top)<0+scroll_top){
crossobj.top=parseInt(crossobj.top)+40+calunits
if (parseInt(crossobj.top)>0+scroll_top){crossobj.top=0+scroll_top}}else{
clearInterval(dropstart)
bouncestart=setInterval("bouncein()",50)}}
function bouncein(){
crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
if (bouncelimit<0)
bouncelimit+=8
bouncelimit=bouncelimit*-1
if (bouncelimit==0){
clearInterval(bouncestart)}}
function dismissbox(){
if (window.bouncestart) clearInterval(bouncestart)
crossobj.visibility="hidden"}
function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body}
</script>

Thanks for all your help!
Please let me know if my description makes no sense.
 
Simply remove the script tags, place the whole lot in an external file, link to it, and you should be set.

WRT your condern about being able to call the code from multiple links - this will be no problem. You will be able to call "PopupMe1" from any link on the page.

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top