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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have 3 External scripts, how do I keep them all running? 2

Status
Not open for further replies.

DBSSP

Programmer
Apr 1, 2002
327
US
I have 3 external javascript files with various functions. I need to know how to keep them all running. It seems the last script accessed is considered the "current" script and the other 2 are shutdown. How do I stop this? Jay [infinity]
"If the words up and down were reversed, would you trip and fall or trip and fly?"
 
make sure all names of functions are different. You cannot have the same names of variables and functions in all three seperate js files. Gary Haran
 
They are all different...most of the variables are the same though...Perhaps I should go down to one main source file and pass variables? If so, how can I do that from buttons?

I.E. User clicks one of 3 buttons, that button should contain varibale information for title, file, & autoclose = True or False. It should call the function in the script and pass all of these variables to the script. Jay [infinity]
"If the words up and down were reversed, would you trip and fall or trip and fly?"
 
warning complicated things ahead.

DBSSP, keep it simple sailor (KISS).

Try to see if there aren't simpler ways of dealing with your problem.

Why are there three js files? Could they be better organised into one? Does your naming convention really work? Gary Haran
 
I checked some things out and I can actually go from 1 file the other 2 were test files...(I didn't know they all were the same thing with variables and all..delete). Sorry about that.

So I'll be calling the same function from each the 3 buttons, each one will just have different values to pass to the same variables in the main file.

click button
pass variables for this button to external script
call function in script
pop up window opens with correct page

Is that a little bit better? It certainly took a load off my mind, although I'm still not out of the woods yet! Jay [infinity]
"If the words up and down were reversed, would you trip and fall or trip and fly?"
 
sounds better the less code you have the less bugs and crap you have in there (it's a law of programming).

If you need any more help try reading my faq on using a coding convention and come back and post your code so we can have some fun helping you! :)

faq216-1736 Gary Haran
 
Okay, I had to do alot of tweaking, but here it is (I tried to get it as simple as I could). The bold areas are the variables that get changed depending on which button is clicked, and, of course, the single function. I've named the file popcalc.js
Thank you for your help thus far!


BEGIN CODE
**************************
// set the popup window width and height

var windowW=583 // wide
var windowH=330 // high
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//Set the screen position where the popup should appear.
// See the following settings.
//***************************************************************
//Programmer Specifies Window Position *
// Un-comment Set 1 & Comment Set 2 out *
//Automatically center on screen *
// Un-comment Set 2 & Comment Set 1 out *
//***************************************************************

//---------------
//Set 1 |
//---------------
//var windowX = 260 // from left
//var windowY = 100 // from top

//---------------
//Set 2 |
//---------------
var windowX = (screen.width/2)-(windowW/2);
var windowY = (screen.height/2)-(windowH/2);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// set the url of the page to show in the popup

var urlPop = "the page.htm"

// set the title of the page

var title = "pop up title"

// set this to true if the popup should close
// upon leaving the launching page; else, false

var autoclose = true

// ============================
// do not edit below this line
// ============================

s = "width="+windowW+",height="+windowH;
var beIE = document.all?true:false

function openFrameless(){
if (beIE){
JMS = window.open("","popFrameless","fullscreen,"+s)
JMS.blur()
window.focus()
JMS.resizeTo(windowW,windowH)
JMS.moveTo(windowX,windowY)
var frameString=""+
&quot;<html>&quot;+
&quot;<head>&quot;+
&quot;<title>&quot;+title+&quot;</title>&quot;+
&quot;</head>&quot;+
&quot;<frameset rows='*,0' framespacing=0 border=0 frameborder=0>&quot;+
&quot;<frame name='top' src='&quot;+urlPop+&quot;' scrolling=auto>&quot;+
&quot;<frame name='bottom' src='about:blank' scrolling='no'>&quot;+
&quot;</frameset>&quot;+
&quot;</html>&quot;
JMS.document.open();
JMS.document.write(frameString)
JMS.document.close()
} else {
JMS=window.open(urlPop,&quot;popFrameless&quot;,&quot;scrollbars,&quot;+s)
JMS.blur()
window.focus()
JMS.resizeTo(windowW,windowH)
JMS.moveTo(windowX,windowY)
}
JMS.focus()
if (autoclose){
window.onunload = function(){JMS.close()}
}
}
*****************************
END CODE Jay [infinity]
&quot;If the words up and down were reversed, would you trip and fall or trip and fly?&quot;
 
I'm trying everything and coming up very empty-empty handed. Anybody? Jay [infinity]
&quot;If the words up and down were reversed, would you trip and fall or trip and fly?&quot;
 
//leave the variable declarations out of any function

var windowW = 583
var windowH = 330
var windowX = (screen.width/2)-(windowW/2);
var windowY = (screen.height/2)-(windowH/2);
var urlPop = &quot;the page.htm&quot;
var title = &quot;pop up title&quot;
var autoclose = true

function popCalc(fWidth, fHeight, fTitle, fUrl, fClose){
//reset variables here...
windowW = fWidth
windowH = fHeight
windowX = (screen.width/2)-(windowW/2);
windowY = (screen.height/2)-(windowH/2);
urlPop = fUrl
title = fTitle
autoclose = fClose
openFrameless()
}


//to call function
<input type=button value=&quot;Open Calc&quot; onClick=&quot;popCalc(340,480,'My Title','pageUrl.htm',true)&quot;


Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048

mikewolf@tst-us.com
 
You know what? You get a star on this one my friend! Thank you so much! Now I have something new to add to my code arsenal! Jay [infinity]
&quot;If the words up and down were reversed, would you trip and fall or trip and fly?&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top