Re: Sometime the JavaScript function becomes undefined
- From: "miher" <feher.zsolt@xxxxxxxxx>
- Date: Tue, 17 Mar 2009 12:20:53 +0100
Hi,
Try to add the reference in code by putting this line into Your master pages Load instead of the <script> block in Your markup:
Page.ClientScript.RegisterClientScriptInclude(GetType(), "scripts", ResolveClientUrl("~/JavaScripts/OpenWindow.js"));
Hope You find this useful.
-Zsolt
"AAaron123" <aaaron123@xxxxxxxxxxxxxx> wrote in message news:eu#rH#opJHA.1172@xxxxxxxxxxxxxxxxxxxxxxx
Your suggestion to use.
"/MySubFolder/JavaScripts..." and
"/MySubFolder/Images..."
fixed it.
But the Hosting site gave me a different folder name to use.
Can't I capture that folder name and store it in a session variable?
Would that be a good way to go?
Thanks for all the help
"Patrice" <http://www.chez.com/scribe/> wrote in message news:401C6DA2-A2CF-4022-A9C6-19453A69AE97@xxxxxxxxxxxxxxxxIs your web application at the root of your web site ? If your web application is the web site root you'll have to use src="/MySubFolder/JavaScripts/OpenWindow.js".
IMO your best best is to check the IIS log as you'll see what is requested and if the file is found or not...
--
Patrice
"AAaron123" <aaaron123@xxxxxxxxxxxxxx> a écrit dans le message de groupe de discussion : efEViampJHA.996@xxxxxxxxxxxxxxxxxxxxxxxIf I do this in the master
<script type="text/javascript" src="/JavaScripts/OpenWindow.js"></script>
and this in the master
<a href="JavaScript:openWindow('Aerial','Ima
I always get openWindow is undefined.
I don't think I'll have a problem adjusting the Images folder
but I don't know why it doesn't find openWindow.
Thanks a lot
ps
Without the leading slash it works ok from Default.aspx which is in the root with the master
"Patrice" <http://www.chez.com/scribe/> wrote in message news:D8EF6F84-865A-4ACD-8471-7AD4B434E39A@xxxxxxxxxxxxxxxxsrc="MyFolder" means the folder that is under the current page location. src="/MyFolder" points to a folder to is under the root.
The master page doesn't play any role here. This is not a separate page. Its content is just merged with the current page (much like a user control).
You can also check this using the IIS log. You should see that your app ask for a js file that doesn't exists...
So you'll have to adjust the js file name. You'll have also the same problem for the Images folder....
The problem is that you are using relative paths so it depends where you are and works only when you are at the root of your site. You should add a leading / to use absolute paths...
--
Patrice
"AAaron123" <aaaron123@xxxxxxxxxxxxxx> a écrit dans le message de groupe de discussion : #sMvE9lpJHA.5280@xxxxxxxxxxxxxxxxxxxxxxxI typed JavaScript in the site map below when I should have written JavaScripts. I revised it.
JavaScripts is at the root level. Your suggestion did not work probably because of my typo.
So it works when the page's .aspx is at root but not when the page is in a subfolder.
When a master is merged with a contents page I think all the file descriptions are adjusted.
1)Right?
However, I'd guess that the quoted string containing openWindow would not be adjusted.
<a href="JavaScript:openWindow('Aerial','Images/Aer..snip..
2)Right?
Maybe it doesn't need to be "adjusted" because it's in some global namespace?
3)Comment?
Thanks
"Patrice" <http://www.chez.com/scribe/> wrote in message news:326BA36B-EC34-4D73-B6FC-8A60BADE73EE@xxxxxxxxxxxxxxxxsrc="JavaScripts/OpenWindows.js"
So the script must in a folder that is called JavaScripts and that is in the same folder than the current ASPX page.
See site map below. JavaScripts is in the root folder.
The anchor calling openWindows is in the master.
It work OK if the contents page is at root level but not with a contents page that is in a subfolder.
I hope this makes more sense to you than it does to me.
Any suggestions?
You may want to try src="/JavaScripts/OpenWindows.js" so that it takes the folder that is named JavaScripts and is at the root of the web site...
--
Patrice
"AAaron123" <aaaron123@xxxxxxxxxxxxxx> a écrit dans le message de groupe de discussion : uyB0H3kpJHA.500@xxxxxxxxxxxxxxxxxxxxxxxIn the master header I have
<script type="text/javascript" src="JavaScripts\OpenWindow.js"></script>
OpenWindow.js contains the function openWindow
In the body of the master I have
<a href="JavaScript:openWindow('Aerial','Images/Aer..snip
When I click the anchor while the page showing is Default.aspx (which is at the root level as is .Master) the window opens OK.
The folder JavaScripts is also at the root level and OpenWindow.js then one level below the root.
If instead of showing Default.aspx which is at the root level I show the page Articles/Articles.aspx I find openWindow is undefined when I click the anchor.
Do you see what is wrong?
Thanks
project
Default.aspx
Main.Master
JavaScripts(folder)
OpenWindow.js (contains function openWindow)
Articles(folder)
Articles.aspx
- Follow-Ups:
- Re: Sometime the JavaScript function becomes undefined
- From: AAaron123
- Re: Sometime the JavaScript function becomes undefined
- References:
- Sometime the JavaScript function becomes undefined
- From: AAaron123
- Re: Sometime the JavaScript function becomes undefined
- From: Patrice
- Re: Sometime the JavaScript function becomes undefined
- From: AAaron123
- Re: Sometime the JavaScript function becomes undefined
- From: Patrice
- Re: Sometime the JavaScript function becomes undefined
- From: AAaron123
- Re: Sometime the JavaScript function becomes undefined
- From: Patrice
- Re: Sometime the JavaScript function becomes undefined
- From: AAaron123
- Sometime the JavaScript function becomes undefined
- Prev by Date: problem setting background image on a link
- Next by Date: Re: problem setting background image on a link
- Previous by thread: Re: Sometime the JavaScript function becomes undefined
- Next by thread: Re: Sometime the JavaScript function becomes undefined
- Index(es):
Relevant Pages
|