Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Why does this fade not work? (jQuery)
Old 01-14-2010, 02:48 PM Why does this fade not work? (jQuery)
Novice Talker

Posts: 5
Trades: 0
Hello, i have the following webpage, but on whatever reason, when i click the button, it does not do anything. Code:

Code:
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>ItsMyWebsite</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js">
function fader() 
{
 $("#logofade").html('<img src="images/logo.gif" alt="Logo" />');
 $("#logofade").fadeOut("slow", function(){
  window.location = "index2.html";
 });
}
</script>    
</head>
    <body>
    <p><input name="logofader" type="button" value="FadeIt" onclick="fader()" /></p>
    <p><span id="logofade"></span></p>
    </body>
    </html>

Last edited by gdscei; 01-15-2010 at 05:30 PM..
gdscei is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-14-2010, 03:30 PM Re: Why does this fade not work? (jQuery)
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Are you expecting the window.location to change AFTER the fade? If so, you should place it into the callback of the fadeOut, not just after it:
Code:
$("#logofade").fadeOut("slow",function(){window.location = "index2.html";});
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 01-15-2010, 01:23 PM Re: Why does this fade not work? (jQuery)
Novice Talker

Posts: 5
Trades: 0
Quote:
Originally Posted by wayfarer07 View Post
Are you expecting the window.location to change AFTER the fade? If so, you should place it into the callback of the fadeOut, not just after it:
Code:
$("#logofade").fadeOut("slow",function(){window.location = "index2.html";});
That doesn't make it work.
I putted it online, http://testfade.gdscei.com , maybe you can figure it out...

I also putted it on Doctype , but that didn't work really...

Last edited by gdscei; 01-15-2010 at 01:24 PM..
gdscei is offline
Reply With Quote
View Public Profile
 
Old 01-15-2010, 04:38 PM Re: Why does this fade not work? (jQuery)
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Well, that would be because jQuery is not being defined anywhere. jQuery support is not included with your browser, you need to include it manually from a script tag.
Code:
<script src="/path/to/jquery.js"></script>
At least this is true for the example you're giving. Your original question seems to have a path to jQuery.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 01-15-2010, 05:29 PM Re: Why does this fade not work? (jQuery)
Novice Talker

Posts: 5
Trades: 0
Quote:
Originally Posted by wayfarer07 View Post
Well, that would be because jQuery is not being defined anywhere. jQuery support is not included with your browser, you need to include it manually from a script tag.
Code:
<script src="/path/to/jquery.js"></script>
At least this is true for the example you're giving. Your original question seems to have a path to jQuery.
Yes, but that doesn't make it work either. (check my edited question)

Last edited by gdscei; 01-15-2010 at 05:31 PM..
gdscei is offline
Reply With Quote
View Public Profile
 
Old 01-15-2010, 05:35 PM Re: Why does this fade not work? (jQuery)
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
I didn't see the problem before, but now I do. You can't have a script that has a src attribute and also inline scripts:
HTML Code:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js">
function fader() 
{
 $("#logofade").html('<img src="http://www.webmaster-talk.com/images/logo.gif" alt="Logo" />');
 $("#logofade").fadeOut("slow", function(){
  window.location = "index2.html";
 });
}
</script>
It seems to me this should be allowed, but it is not. You'll need to put them in two separate SCRIPT tags like this:
HTML Code:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
<script type="text/javascript">
function fader() 
{
 $("#logofade").html('<img src="http://www.webmaster-talk.com/images/logo.gif" alt="Logo" />');
 $("#logofade").fadeOut("slow", function(){
  window.location = "index2.html";
 });
}
</script>
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 01-16-2010, 06:11 AM Re: Why does this fade not work? (jQuery)
Novice Talker

Posts: 5
Trades: 0
Quote:
Originally Posted by wayfarer07 View Post
I didn't see the problem before, but now I do. You can't have a script that has a src attribute and also inline scripts:
HTML Code:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js">
function fader() 
{
 $("#logofade").html('<img src="http://www.webmaster-talk.com/images/logo.gif" alt="Logo" />');
 $("#logofade").fadeOut("slow", function(){
  window.location = "index2.html";
 });
}
</script>
It seems to me this should be allowed, but it is not. You'll need to put them in two separate SCRIPT tags like this:
HTML Code:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
<script type="text/javascript">
function fader() 
{
 $("#logofade").html('<img src="http://www.webmaster-talk.com/images/logo.gif" alt="Logo" />');
 $("#logofade").fadeOut("slow", function(){
  window.location = "index2.html";
 });
}
</script>
Thank you! Works! Do you know how to get it slower? the fadeOut is still going quite fast.
gdscei is offline
Reply With Quote
View Public Profile
 
Old 01-16-2010, 06:15 AM Re: Why does this fade not work? (jQuery)
Novice Talker

Posts: 5
Trades: 0
Quote:
Originally Posted by gdscei View Post
Thank you! Works! Do you know how to get it slower? the fadeOut is still going quite fast.
nevermind, got that.
gdscei is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Why does this fade not work? (jQuery)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.48893 seconds with 12 queries