Firefox not loading some external Javascripts [closed] - javascript

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
SOLVED Argh. I HATE when this happens. It was just me being stupid. I didn't allow crtypto-js.googlecode.com to run javascript in NoScript. Sorry for bothing you, and thank you all for your help!
Update It works for other people in Firefox, and it works for me in Internet Explorer. SO this sin't related to the HTML code itself it seams. I might head over to SuperUser if nobody has an idea here. (ANd yepp - I have tried emptying the cache ^^)
I just ran into a strange problem. In a XHML document, I'm loading three javascript libraries. One loads, two don't. When checking with firefox internal web developer console, I see no requests issued for the two, so it's not wrong paths or anything (I would see requests returnign 404).
Minimal Example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html version="-//W3C//DTD XHTML 1.1//EN" xml:lang="en"
xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/1999/xhtml http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd">
<head>
<script type="text/javascript" src="//crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/hmac-sha1.js" />
<script type="text/javascript" src="//crypto-js.googlecode.com/svn/tags/3.1.2/build/components/enc-base64-min.js" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" />
<script type="text/javascript"></script>
</head>
<body>
</body>
</html>
Screenshot of browser console:
What's going on here? Sourcecode looks fine to me, and the script tags loading CryptoJS are structured the same way as the one that loads jQuery. Still, jQuery loads while the others don't.
[Edit]: JUst to make that one clear in case more people are about to answer the same: self-closing the emtpy script-tags is fine. It's valid XHTML, and the current verwsion of FIrefox is fully XHTML compliant and understands this. If you read that you should not do this somewhere - that's right, you shouldn't. Because you could still meet old, non-XHTML-compliant browsers. But this is a private test-project that will never be used anywhere outside my own browser, So this is a non-issue here.

<script> cannot be self-closing, as shown by the syntax highlighting in your question.
Always close scripts with </script>.

Problem solved. NoScript blocked the two Javascripts.

Related

Html file not reading .js? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
This question has been asked ~10^4 times, but hear me out that I've done my due dilligence in reading the solutions and seeing if their tweaks fix things (to no avail). I'm an amateur when it comes to JS/CSS/HTML but I'm learning. I am trying to implement this sticky navigation bar from here (also see here). My question isn't about their code, which appears to be fine.
When I implement it, my .html file doesn't seem to be using the .js script at all. None of the buttons respond, I don't get any errors, but everything in the .css and .html files otherwise are rendering fine. The head:
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<script type="text/javascript" src="script.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
</head>
...
</html>
The script.js should be in the correctly referenced directory.
Answer (as I was writing this): The jquery script and the custom script were in the wrong order. :)

JavaScript: Can the entire page be loaded dynamically? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
When I try to go to Gmail and FaceBook with my JavaScript disabled, I am greeted with the following:
The content in the images is displayed in <noscript> tags, but the rest of the usual page content isn't there. The Gmail source has a few empty <iframe> elements, but the FB page is empty, save for the <noscript> element, and a couple <script> tags.
I would like to have similar behaviour for my site, but am unsure how to only load the page content if the user has JS enabled. I can put in the <noscript> element, and have a div centred on screen with a "You need JS enabled" message, but the rest of the content would still have loaded behind it.
There are a couple solutions here and here, but they only have the main content as:
display: none;
and the set it to block; via JS. But that would still show up in the source.
Can I entirely prevent loading page content when JS is disabled, and only display the "Oops, you need JS enabled" message?
Do not put the content in the first page, and just put a <script src="…"> which loads the actual contents via AJAX. Your source should then roughly follow that template:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="libraries.js"></script>
<script src="load-page-contents.js"></script>
</head>
<body>
<noscript>
This website is an interactive editor for 3D graphics or something
really complex that can't be done at all in plain HTML, and therefore
needs JavaScript.
Click here to read more about this project.
<img src="screenshot.jpg" alt="Obligatory screenshot, to compell the
user to turn on JavaScript because this looks So Cool ™." />
</body>
</html>
Think twice about it, however. Does your site really need JavaScript to work? Can't at least a dumbed-down version be displayed otherwise? There are lots of reasons to have JavaScript disabled (screen readers, search engines, security issues, easy way to disable lots of blinking flashing annoying ads)
Simply load the whole page with an AJAX request and hide the error message using Javascript. Then the error message will remain if they have Javascript disabled, and the page will be loaded if it is enabled.

JavaScript Failure

I try to learn how to write Javascript but I have found a problem either so basic I would never think about it or so complicated that I lack the knowladge to find it.
I am Using NetbeansIDE 8.0 .
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<head>
<title>Objekt Navigator</title>
</head>
<body>
Something<br/>
<script language="javascript" type="text/javascript">
document.write("Text");
alert("Bla bla");
</script>
Else<br/>
</body>
</html>
If the compiled page is opened it will only display "Something" and "Else" but nothing of the script.
If I remove "document.write("Text");" it will show the alert but there is no wrong wording in "document.write".
I really need one (or more) pointers to understand this.
Pointer 1:
Don't use document.write. Really. It has been archaic and obsolete for at least 15 years, if not 20. Use regular DOM methods.
Whatever tutorial you found that in, choose something else.
Pointer 2: Don't use XHTML. Use the HTML5 Doctype. The XHTML one does some very weird things with JavaScript -- IF the file is being served as XHTML.
Lastly: your code works just fine for me. If this is not the exact code that you are using in your tests, look at your console.log to see if you have an error somewhere.

White Flash on First Page Load: Can this be "fixed?" [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I've noticed that on the first load of some of the pages on my site, there's a quick white flash.
It doesn't seem to do this once the page content has been cached, but it's annoying during the first loads.
I tried styling all of the <html> tags black, but that doesn't seem to solve the issue. Could it be the scripts on some of my pages? (i.e. maybe analytics)
Is there anything I could do to remedy this problem?
Update: The site can be viewed here. Some pages have Javascript, but others do not, and it seems that's irrelevant, based on the results I've experienced.
OK, so it looks like this might be related to your script tag in the <head/>. Try pushing that down to just before the closing </body> tag. The document can't render until that script has completely run.
See rule 6
However, one of the other resource you're waiting on sometimes is 'home.css'. That may even be more of a problem. It's a bit of a hack, but you could try setting your background to black before even that css using an inline <style/> tag.
Try structuring the page in this order (notice the <style/>) tag;
<!doctype html>
<html>
<head>
<style>
html { background-color: black; }
</style>
...
<link href="home.css" rel="stylesheet" type="text/css">
...
</head>
<body>
...
<div id="footer">
<span class="footer_text">Copyright © 2013 Casey Kidd Music.<br />All Rights Reserved.</span>
</div>
</div>
<script>
(function(
...
'pageview');
</script>
</body>
</html>
It's possible you may still get a small flicker of white between pages, before the HTML has loaded, but this window would be pretty small now.

Javascript code ignored in web-resource

I've got a page I'm adding as a Web Resource in a dynamics CRM form. I've developed the code outside the iframe and it works standalone in IE (9+) and Firefox navigating directly to the resource URL. (edited)
Coming back to testing the code embedded in CRM after a days standalone development and now; none of the scripts run when loaded as part of the CRM form. I've tested this by adding small alert scripts at every stage of the javascript load (as follows), now these work in all browsers as far back as IE5, but not when loaded within an IFrame on the CRM form:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
alert("1");
</script>
<!-- etc.. -->
I've also tried creating a local page to load my page in an iframe which also works as expected:
<!DOCTYPE html>
<html>
<head>
<title>Iframe test</title>
</head>
<body style="background: Red;">
<h1>Hello, World!</h1>
<iframe width="500" height="500" src="http://server:5555/...">
</iframe>
</body>
</html>
as this issue only occurs in an IFrame I've run out of ideas for how to debug it. My best guess would be the issue is a conflict with code in the parent page but even then I'd expect my alert at the entry point of the html file would run.
I'm not sure at what point yesterday the code stopped working and don't have a backup unfortunately. I'd appreciate any speculation on why scripts would be abandoned within an IFrame, tips on any extra debugging steps I could try... or a solution =p.
Turned off "Restrict Cross-frame scripting" in the properties for the web-resource on the form which solved the issue.
Thanks for all the help though!
Have you tried adding it as a web resource rather than an iframe? There could be some xss security kicking in. Web Resource should get over that. The Web Resource also has other advantages (dependency aware etc).

Categories

Resources