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

declare var outside the function

Status
Not open for further replies.

nivini

Programmer
Mar 24, 2004
64
0
0
I have this code
Code:
<script language="JavaScript">
<!--
var newPic = NULL;
var FSO;
function OpenPic(strPath){
var newPath=strPath;
var fullPath;
fullPath =newPath.replace("..","");
newPath="F:/web/webserver/[URL unfurl="true"]www/Pages"[/URL] + fullPath;
 FSO = new ActiveXObject("Scripting.FileSystemObject");

if  (FSO.FileExists(newPath)==true)
{
newPic=window.open(strPath,"NULL" ,"width=400, height=300, toolbar=no, resizable=no, menubar=no, top=0, left=0");
}
else
{
newPic=window.open("NoPic.htm","NULL" ,"width=400, height=300, toolbar=no, resizable=no, menubar=no, top=0, left=0");
};


};

function CloseWin(){
newPic.close();
};
-->
</script>
the onmouseover trigers the OpenWin function, and the onmouseout , trigers the CloseWin function.
The problem is that it all works fine on my machine, but not on the web, there i get an error says that newPic is null or undefined,
What is the problem with this code?
many thanks
nivini
 
It sounds like you're calling the close function before newPic is populated. Try this:

Code:
function CloseWin(){
	try {
		newPic.close();
	} catch(e) {}
};

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I forgot to mention, when the code was:
Code:
script language="JavaScript">
<!--
var newPic 
function OpenPic(strPath)
{
newPic=window.open(strPath,"NULL" ,"width=400, height=300, toolbar=no, resizable=no, menubar=no, top=0, left=0");
};

function CloseWin()
{
newPic.close();
};
-->
</script>
it all workwd fine on the web, but when i added the fso object the problems began, what could be the resson for this?
Dan, i tried your solution,but, no go, please if you have other sugestion it will be great
thank
nivini
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top