0

I have the following page in a jQuery mobile site:

<div data-role="page" id="myPage">
   <script type="text/javascript">alert("test");</script>
   <script src="https://someexternalscript.js"></script>
</div>

The first script tag, with the script contained in it, is evaluated properly. Every time I navigate to the page, an alert is shown. The second script tag however, is only evaluated when I navigate the browser directly to this page. When I navigate through the site itself, it isn't being evaluated. I noticed with Fiddler that the source is being downloaded, it just doesn't seem to be evaluated.

Any ideas what could be causing this, and how it could be resovled?

3
  • Isn't that what the page role is about? Only show /run the stuff defined within the page? Commented Sep 6, 2013 at 9:43
  • That's fair enough. But in my case the javascript actually defines (most of) the content of the page. And I can't really change that because it's a third-party product. Commented Sep 6, 2013 at 13:41
  • Late, but I just answered this here: stackoverflow.com/questions/24941859/… Commented Jul 24, 2014 at 20:11

1 Answer 1

1

script tag is is not self closing tag, so you need to close it using </script>

Sign up to request clarification or add additional context in comments.

5 Comments

Ah yes, little mistake when writing this question. My code did have it closed properly. So that's not it :)
@PJanssen well i thought that was the problem, but other problem might be same domain origin problem as you can not load different domain content
I have considered that too. But then why would it work fine when I refresh the page or navigate there directly with the browser?
@PJanssen that the policy dude...you can access it from same domain but from other domain you need some auth_tokens
I'm not navigating to the location of the javascript, but to the location of the page. So it's still loading from a different domain, and working! But only when navigating directly to the specific page through the browser.

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.