Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

Javascript and Jquery not firing

In my code below...
My code is ALWAYS loading the favicon.ico.

Even though... my alert works and tells me that it should swap out based on url.


<script type="text/javascript">
    $(window).load(function () {
        var id = document.location.href.toString().indexOf("verif");
        var n
        if (id == -1) {
            $('head').append('<link href="favicon2.ico" rel="shortcut icon" type="image/x-icon" />');
        }
        else {
            $('head').append('<link href="favicon.ico" rel="shortcut icon" type="image/x-icon" />');
        }
        alert(id);
});
</script>

Open in new window

Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

While your code would probably work to change an image in the 'body' of a page, I'm not sure that changing 'favicon.ico' in the 'head' after the page loads like that will have any effect.  'favicon.ico' is the 'standard' file name that browsers look for.  If there isn't any 'favicon.ico' already defined in the 'head' section, I don't think the browser will go back and look again.  It will just try to load the 'standard' version.
Avatar of Larry Brister

ASKER

That same code works on a Master page
Just not a regular aspx page
if it work on a master page, just be sure to have jquery plugin correctly referenced, there's no other difference IMHO
Leakim'
What should the reference be?
SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Taking a look guys
azarc3 and leakim971
I agree... something is profoundly weird here.
Both of your suggestions get me working locally with the Login page as well as the Master Page

But on the actual server... the Master works and the login does not.

I will award points on this question splitting them for you both and formulate a new question after reviewing other possibilities.
Thaks folks