.js references from content to master don't work

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved
Reply

Join Date: Nov 2008
Posts: 4
Reputation: xzajox is an unknown quantity at this point 
Solved Threads: 0
xzajox xzajox is offline Offline
Newbie Poster

.js references from content to master don't work

 
0
  #1
Nov 8th, 2008
Hi, I'm having this problem and can't get a solution anywhere.

-- <Introduction:>
I have a master page, then I have a content page which contains a little login form wrapped in <div id="LoginTable"></div>

What I want, is to use a ScriptaculoUs JavaScript
Effect.Highlight(...)
on some mouseovers.
The Effect.Highlight is in external .js file. Scriptaculous uses also Prototype.


--<Problem>
On a standalone page it worked fine,
I referenced the "Scriptaculous.js" and "Prototype.js" in the <head> tags,
then I added a <script> tag with a function: HiEffect(element){ Effect.Highlight(...) }
then I added onmouseover="HiEffect(this)" to the element.

Everything worked fine until I had to put this page under a MasterPage.

Now, even if I reference the files in the MasterPage or ContentPage, the script won't run.


--<What Worked>
I tried instead of putting Effect.Highlight() something regular, like alert("lol") and the mouseover worked, so OK, the <script> can be found.
Then I checked if the element can be found, Yes, it is found.

So the problem surely is in the reference to the external .js file.
Where to put it, or how to force the page to know where to look for it?


Does anyone know, please let me know, thanx a lot.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 4
Reputation: xzajox is an unknown quantity at this point 
Solved Threads: 0
xzajox xzajox is offline Offline
Newbie Poster

Re: .js references from content to master don't work

 
0
  #2
Nov 19th, 2008
lol 230 views, and nobody can help?
maybe it is a big problem, or was I misunderstood?
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 167
Reputation: Drew is an unknown quantity at this point 
Solved Threads: 7
Drew's Avatar
Drew Drew is offline Offline
Junior Poster

Re: .js references from content to master don't work

 
0
  #3
Nov 19th, 2008
It really helps if you can post some code, or link to some code, and include any error messages.
Drew Gauderman
ASP / MSSQL Coder
http://www.iportalx.net - My ASP Portal
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 4
Reputation: xzajox is an unknown quantity at this point 
Solved Threads: 0
xzajox xzajox is offline Offline
Newbie Poster

Re: .js references from content to master don't work

 
0
  #4
Nov 20th, 2008
Aw, yes, sorry.

this is my master Page:

  1. <head runat="server">
  2. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
  3. <title>my web</title>
  4. <link rel="stylesheet" type="text/css" href="StyleSheet.css" />
  5. <script src="/Javascript/prototype.js" type="text/javascript"></script>
  6. <script src="/Javascript/scriptaculous.js" type="text/javascript"></script>
  7. <script src="/Javascript/effects.js" type="text/javascript"></script>
  8.  
  9. <script type="text/javascript" language="javascript">
  10. function mp_onload()
  11. {
  12. if(window.body_onload != null)
  13. window.body_onload();
  14. }
  15. </script>
  16.  
  17. <script type="text/javascript">
  18. function EffectAppear(elem)
  19. {
  20. Effect.Appear(elem, { duration: 2.0 })
  21. }
  22. </script>
  23.  
  24. </head>
  25. <body onload="mp_onload()">
  26. <form id="form1" runat="server">
  27. <div>
  28. <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
  29. </asp:contentplaceholder>
  30. </div>
  31. </form>
  32. </body>
  33. </html>

this is my content Page:

  1. <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" Title="Login" %>
  2.  
  3. <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
  4. <script type="text/javascript" language="javascript">
  5. function body_onload()
  6. {
  7. EffectAppear(findTable());
  8. }
  9.  
  10. function findTable()
  11. {
  12. var tab = '<%= LoginTable.ClientID %>';
  13. return tab;
  14. }
  15.  
  16. </script>
  17.  
  18. <div>
  19. <table cellpadding="0" cellspacing="0" style="width:100%; height:100%;">
  20. <tr style="height:30%;">
  21. <td style="width:43%;"></td>
  22. <td style="width:14%; height: 150px;" align="center" valign="bottom">
  23. <asp:Label ID="Label4" runat="server" ForeColor="Red" Text="Message" Visible="False"></asp:Label></td>
  24. <td style="width:43%;"></td>
  25. </tr>
  26. <tr style="height:20%;">
  27. <td style="width:43%;"></td>
  28. <td style="width:14%;">
  29. <div id="LoginTable" class="dialog" style="display:none;" runat="server">
  30. <div class="content">
  31. <div class="t"></div>
  32. <table cellspacing="0" style="width:100%; height:100%; border-right: black 0px solid; border-top: black 0px solid; border-left: black 0px solid; border-bottom: black 0px solid;" border="2">
  33. <tr>
  34. <td colspan="2" align="center" style="border-right: 0px solid; border-top: 0px solid; border-left: 0px solid; border-bottom: 0px solid;">
  35. <asp:Label ID="Label1" runat="server" Text="Prihlásenie"></asp:Label></td>
  36. </tr>
  37. </table>
the table goes on, but it is not important.
codebehind files are also not important.

What this is doing: When the page loads, the <div> 'LoginTable' should appear slowly.

ERROR messages. Yes, I use Firebug and it tells me this:

Effect is not defined:
Effect.Appear(elem, { duration: 2.0 })

So it is obvious that the external file effects.js cannot be found.
I know I don't need to put the <script> reference to effects.js, because the file scriptaculous.js loads it itself, but still, the file can not be found or what.

hope this helps, thx.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 4
Reputation: xzajox is an unknown quantity at this point 
Solved Threads: 0
xzajox xzajox is offline Offline
Newbie Poster

Re: .js references from content to master don't work

 
0
  #5
Nov 20th, 2008
WHAT THE HELL?

I resolved it by accident. I almost gave up.

I simply moved the <script> references
from the <head> of the Master Page
into the <body><form> tag

and it worked...

lol, I spent hours googling around and found nothing.

I Hope if anybody`s got this noob (that`s me) problem, here is the solution.

Anyway, thanx Drew, and to everybody who wanted to help
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC