Jquery document load whoes

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Jquery document load whoes

Post by John Cartwright »

I'm whipping up a quick form for my friend, however I am going mad trying to figure out why the following document ready does not work. This problem only occurs in Firefox. When loading the page normally, nothing within the document block is run. However, if I visit another page and back my back button everything runs perfectly. I've cleared my cache, hard refreshed, rebooted, but I simply cannot get this to work in my Firefox!

I have absolutely no idea why such a simple thing is not working (I must be missing something obvious?).

Does anyone have any clues as to what is causing this? I've attached the code below.

Thanks for reading.

Code: Select all

 
<!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" xml:lang="en" lang="en">  
<head>
    <title>Foobar</title>
    <script src="js/jquery.js" type="text/javascript"></script>
 
    <script language="javascript" type="text/javascript">
        $(document).ready(function(){
                alert('hi');
        });
        </script>   
User avatar
Syntac
Forum Contributor
Posts: 327
Joined: Sun Sep 14, 2008 7:59 pm

Re: Jquery document load whoes

Post by Syntac »

That sort of thing doesn't work properly if you stick it in the <head> section, if I remember correctly. Try putting it in the <body> instead.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Jquery document load whoes

Post by John Cartwright »

I had actually tried that earlier, actually. This attempt showed no difference :banghead:

It's also worth mentioning the document was xhtml 1.0 valid.
User avatar
Syntac
Forum Contributor
Posts: 327
Joined: Sun Sep 14, 2008 7:59 pm

Re: Jquery document load whoes

Post by Syntac »

Maybe Firefox is just messed...
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Jquery document load whoes

Post by John Cartwright »

Something is most definitely retarded with firefox. I copy and pasted the headers from another website of mine, and I can get the document ready function to work just fine.

Code: Select all

 
<!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>
<title>***</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link rel="stylesheet" type="text/css" href="/css/cake.generic.css" />
<script language="javascript" src="js/jquery.js" /></script>
<script language="javascript" src="/js/jquery.popupfreeze_support.js" /></script>
 
<script language="javascript" type="text/javascript">
    $(document).ready(function(){
           alert('hi');
        });
This is where things get really weird. All I could change was the title, and the jquery script inclusion. If I change a single character other than those two lines it will revert back to not working.

I'm lost.

Since this is only for a friend and not a client I'm not going to pursue this furthur and just use this. However, I am very interested in knowing what the heck is the cause. Caching gone awry perhaps?
User avatar
Syntac
Forum Contributor
Posts: 327
Joined: Sun Sep 14, 2008 7:59 pm

Re: Jquery document load whoes

Post by Syntac »

Odd. Try making sure all the tags are closed correctly (I know, I know, just making sure).

What's popupfreeze_support? Sounds useful.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Jquery document load whoes

Post by John Cartwright »

Indeed everything was closed properly and was xhtml 1.0 validated.
What's popupfreeze_support? Sounds useful.
It's a custom made lightbox I made with jquery (before all the cool ones existed). The ones available now are much more useful :)

Thanks for the help nonetheless.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Re: Jquery document load whoes

Post by JellyFish »

Why not try using:

Code: Select all

 
$(function() {
  alert("hi");
});
 
instead? I don't know if it will help but it's worth a try.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Jquery document load whoes

Post by jaoudestudios »

Why not try putting it in a *.js file and load the external file? Sounds silly, but may be worth a try?!?!
Post Reply