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
Hiding something for X amount of time using jQuery
Old 08-16-2010, 02:47 PM Hiding something for X amount of time using jQuery
bjornh's Avatar
Novice Talker

Posts: 13
Location: Norway
Trades: 0
Hey,

When my index page loads in Internet Explorer, a message is displayed. It's handled as follows:

The index.html page has this line at the bottom, right before the </body> tag:
Code:
<!--[if IE]>
<!--#INCLUDE FILE="nav_ie.htm" -->
<![endif]-->
And "nav_ie.htm" has the following contents:
Code:
<div id="ie">
<center>
<br />
<font face="Diablo Light">System Error!</font><br /><br />
It seems that you are using <b>Internet Explorer</b>..<br />IE is slow and lacks a lot of capabilities.<br />Maybe IE9 will be better..<br />
Please consider trying <a target="_blank" href="http://www.w3schools.com/browsers/">another</a> browser.<br /><a target="_blank" href="http://www.google.com/chrome/">Chrome</a> is very good.<br /><br />
<span onclick="if(document.getElementById('ie').style.display=='none') {document.getElementById('ie').style.display='block';} else {document.getElementById('ie').style.display='none';}" style="color: #AAA168;" title="This message will now hide for 1000 days or until you clear cookies. But please - Try another browser :)">
- Hide -<br />
</span>
<font size="0.875em">(1000 days)</font>
</center>
</div>
<script type='text/javascript'>
While this is all good and displays in a somewhat subtle matter, and only on one page, I'd like to inquire whether it'd be possible to have jQuery hide this message for say, 10 days when the "- Hide -" text is clicked?

Thanks for reading.
__________________

Please login or register to view this content. Registration is FREE

Last edited by bjornh; 08-17-2010 at 04:37 AM..
bjornh is offline
Reply With Quote
View Public Profile Visit bjornh's homepage!
 
 
Register now for full access!
Old 08-16-2010, 03:26 PM Re: Hiding something for X amount of time using jQuery
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
BTW it is rather unprofessional to comment on a users choice of browser. They may not have any choice in the matter.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-16-2010, 05:39 PM Re: Hiding something for X amount of time using jQuery
bjornh's Avatar
Novice Talker

Posts: 13
Location: Norway
Trades: 0
As a subtle message on a somewhat obscure game fansite (and on only one page) it's less of an issue than on cnn.com's frontpage. I know that people are using their father's computer, they're in a library, an internet café, at work etc.

Why just sit back and accept that IE's lack of capabilities must continue forcing everyone to spend hours and hours just to cover for them? They should take responsibility and make sure that things work right. Let's say there are 10,000,000 people in this world having to spend 100 hours each of their lives just because of this.. the math is easy and that's a careful estimate. This is why Microsoft should take responsibility.

Not to mention that Microsoft are effectively denying people the possibility of using cool design technologies.

I'm trying to make this as little intrusive as possible.
__________________

Please login or register to view this content. Registration is FREE

Last edited by bjornh; 08-16-2010 at 06:13 PM..
bjornh is offline
Reply With Quote
View Public Profile Visit bjornh's homepage!
 
Old 08-16-2010, 05:49 PM Re: Hiding something for X amount of time using jQuery
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
IE6 was a poor browser. It has improved since then.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-16-2010, 06:20 PM Re: Hiding something for X amount of time using jQuery
bjornh's Avatar
Novice Talker

Posts: 13
Location: Norway
Trades: 0
Yes it has fortunately but it's still a bit lacking. If IE9 lives up to standards then it's all good.

But I don't want this message to appear more than once for each user, which is why I'm asking for help (atm when you hide the message it gets reloaded on next page refresh).
__________________

Please login or register to view this content. Registration is FREE
bjornh is offline
Reply With Quote
View Public Profile Visit bjornh's homepage!
 
Old 08-16-2010, 07:30 PM Re: Hiding something for X amount of time using jQuery
Crimson's Avatar
Skilled Talker

Posts: 56
Name: Connor
Location: United States
Trades: 0
Quote:
Originally Posted by bjornh View Post
Yes it has fortunately but it's still a bit lacking. If IE9 lives up to standards then it's all good.

But I don't want this message to appear more than once for each user, which is why I'm asking for help (atm when you hide the message it gets reloaded on next page refresh).
The simplest option is to use cookies:

Code:
<script>

function createCookie(name, value, days) {
    if(days){
        var date = new Date();
        date.setTime(date.getTime() + (days*24*60*60*1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires;
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while(c.charAt(0)==' ')
            c = c.substring(1, c.length);
        if(c.indexOf(nameEQ) == 0)
            return c.substring(nameEQ.length, c.length);
    }
    return null;
}

if(readCookie("iecheck")){
    // if user has been here before, hide warning
    $('#ie').hide();
} else{
    // if first time, set cookie
    createCookie("iecheck", "1", daysToHide=10);
}

</script>
Hope that helps.
-Connor
__________________

Please login or register to view this content. Registration is FREE

I solve code problems, browser compatibility (including IE 6), Wordpress trouble, the works.

Last edited by Crimson; 08-16-2010 at 07:32 PM..
Crimson is offline
Reply With Quote
View Public Profile Visit Crimson's homepage!
 
Old 08-17-2010, 04:42 AM Re: Hiding something for X amount of time using jQuery
bjornh's Avatar
Novice Talker

Posts: 13
Location: Norway
Trades: 0
Crimson, thank you very much for your help. The code worked right out of the box.

I decided to just set 1000 days instead and I hope that this message will 'convert' more people than it scares away.. hehe. I hope no-one is scared off because of this though.

Now the "nav_ie.htm" file looks like this:
Code:
<div id="ie">
<center>
<br />
<font face="Diablo Light">System Error!</font><br /><br />
It seems that you are using <b>Internet Explorer</b>..<br />IE is slow and lacks a lot of capabilities.<br />Maybe IE9 will be better..<br />
Please consider trying <a target="_blank" href="http://www.w3schools.com/browsers/">another</a> browser.<br /><a target="_blank" href="http://www.google.com/chrome/">Chrome</a> is very good.<br /><br />
<span onclick="if(document.getElementById('ie').style.display=='none') {document.getElementById('ie').style.display='block';} else {document.getElementById('ie').style.display='none';}" style="color: #AAA168;" title="This message will now hide for 1000 days or until you clear cookies. But please - Try another browser :)">
- Hide -<br />
</span>
<font size="0.875em">(1000 days)</font>
</center>
</div>
<script type='text/javascript'>

function createCookie(name, value, days) {
    if(days){
        var date = new Date();
        date.setTime(date.getTime() + (days*24*60*60*1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires;
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while(c.charAt(0)==' ')
            c = c.substring(1, c.length);
        if(c.indexOf(nameEQ) == 0)
            return c.substring(nameEQ.length, c.length);
    }
    return null;
}

if(readCookie("iecheck")){
    // if user has been here before, hide warning
    $('#ie').hide();
} else{
    // if first time, set cookie
    createCookie("iecheck", "1", daysToHide=1000);
}

</script>
__________________

Please login or register to view this content. Registration is FREE
bjornh is offline
Reply With Quote
View Public Profile Visit bjornh's homepage!
 
Old 08-17-2010, 04:49 AM Re: Hiding something for X amount of time using jQuery
Junior Talker

Posts: 1
Name: pretybot87
Trades: 0
I don't know how old this is. Things like this tend to resurface for circulation every once in a while. My friend sent me the link recently and I thought I'd share. It's the SMB theme played on two guitars...by one kid...at the same time...crazy.


Watch The Expendables Movie Online for Free
Watch Scott Pilgrim Vs. the World Movie Online for Free
pretybot87 is offline
Reply With Quote
View Public Profile
 
Old 08-17-2010, 10:21 PM Re: Hiding something for X amount of time using jQuery
Junior Talker

Posts: 2
Name: vvxifeng
Trades: 0
I very much agree with the above mentioned .. I will continue to monitor the
vvxifeng16 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Hiding something for X amount of time using 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.65301 seconds with 12 queries