0

I have two pages. First one is index.html which has a script to load a second page. The second page has a jquery script that is supposed to run and show a alert.

In the code that is shown below i have removed all extra stuff to simplify my question.

Code for index.html:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v = "urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />

    <title>Testing</title>
    <link type="text/css" rel="stylesheet" href="./review/includes/look.css" />
  </head>
  <body class="review offline" tabindex="0">
    <div id="sidepanel" class="hidden">
      <div class="section" >
        <div id="navigation" class="rounded-border">
          <ul id="navigationtree">
            <li class="leaf last" title="Home">
              <ins class="icon">&nbsp;</ins><a href="screens/alertPage" tabindex="-1"></a>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <div id="jim-mainWindow">
        <div id="jim-body" class="full web" >
            <div id="simulation" class="firer"></div>

        </div>
    </div>

    <script type="text/javascript" src="./review/includes/j.js"></script>
    <script type="text/javascript">jQuery(document).ready(function(){jimMain.init("screens/alertPage");});</script>
  </body>
</html>

The code for the second page is:

<html>
  <body>

    <script src="jquery-1.10.1.js"></script>
    <script>
        jQuery(document).ready(function(){
            alert("hi there");
            }
        }
    </script>
  </body>
</html>

1) I have made sure the jquery-1.10.1.js page is in the same directory as alertPage.html 2) I have validated that alertPage.html is actually being loaded by index.html by adding from UI to alertPage and seeing it being rendered.

What am i missing here?

8
  • 3
    you forgot to include jquery in the first html file Commented Nov 11, 2013 at 19:23
  • you wrote .ready( ... } Commented Nov 11, 2013 at 19:25
  • @karthikr the index.html has j.js and it is properly loading the second alertPage.html as i noted. Commented Nov 11, 2013 at 19:28
  • if you are .loading the second page... don't include jquery again because it will overwrite the jquery on the original page. It's generally a bad idea to .load in html that contains javascript anyway. Commented Nov 11, 2013 at 19:38
  • @kevin if i was to move the script from alertPage to index.html can i refer to the div in alertPage.html from the script in index.html? Commented Nov 11, 2013 at 19:52

2 Answers 2

4

Missing ), extra }

jQuery(document).ready(function(){
    alert("hi there");
    //Remove the }
}); //<---Add the );
Sign up to request clarification or add additional context in comments.

1 Comment

this did not do the trick. Still do not see the alert popup. I am testing on the latest version of firefox.
0

Load your custom js after you have loaded in jQuery

<script src="jquery-1.10.1.js"></script>
<script type="text/javascript" src="./review/includes/j.js"></script>
<script>
    jQuery(document).ready(function(){
        alert("hi there");
    });
</script>

4 Comments

that did not make a change. the custom js is on index.html and the jquery-1.10.1.js is being loaded on alertPage.html.
Does the custom js file contain jQuery? If so, you will need to include that in your index.html.
i included the line as you suggest but that did not change the output.
@codeNinja - grrr!!! OK update your question to include your custom js and I will try and reproduce the error using all your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.