Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4080858
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:59:04+00:00 2026-05-20T17:59:04+00:00

I found (from this question – Hide div if screen is smaller than a

  • 0

I found (from this question – Hide div if screen is smaller than a certain width) this piece of coding

  $(document).ready(function () {

    if (screen.width < 1024) {
        $("#floatdiv").hide();
    }
    else {

        $("#floatdiv").show();
    }

});

The only problem is, I cannot seem to get the code to work, I only need to code to work for IE, I’m going to use Media Queries for other (newer) browsers.
Any hints/tips on where I’m going wrong?

So far I have
<div id="floatdiv">

Then at the end of that div (where is closes) I have

<!--[if lt IE 9]>
<script type="text/javascript" src="http://dl.dropbox.com/u/17087195/website/sidebar_size.js"></script>
<![endif]-->

In my header I have
<script type='text/javascript' src='http://www.itsdaniel0.com/wp-includes/js/jquery/jquery.js?ver=1.4.4'></script>

And I still cannot get the code to work (testing in IE8)
Am I still going wrong somewhere?

Update I do have another piece of jQuery linked, could this be causing the issue? Here is the full piece of coding below

<div id="floatdiv">

<div class="floating-menu">

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.itsdaniel0.com%2F2011%2F03%2Funicorns-are-cool%2F&amp;layout=box_count&amp;show_faces=true&amp;width=55&amp;action=like&amp;colorscheme=light&amp;height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:55px; height:65px;" allowTransparency="true"></iframe>

<br /><br /><a href="http://twitter.com/share?url=http%3A%2F%2Fid0.me%2Fj0&amp;counturl=http://www.itsdaniel0.com/2011/03/unicorns-are-cool/" class="twitter-share-button" data-text="Unicorns Are Cool" data-count="vertical" data-via="itsdaniel0 #itsdaniel0">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>

<br /><br />

<script src="http://widgets.fbshare.me/files/fbshare.js"></script>

</div>

</div>

<script type="text/javascript" src="http://dl.dropbox.com/u/17087195/website/sidebar.js"></script>

<!--[if lt IE 9]>

<script type="text/javascript" src="http://dl.dropbox.com/u/17087195/website/sidebar_size.js"></script>

<![endif]-->

Error Message

Webpage error details

User Agent: Mozilla/4.0 (compatible;
MSIE 7.0; Windows NT 5.1; Trident/4.0;
chromeframe/10.0.648.133; .NET CLR
1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveConnector.1.5;
OfficeLivePatch.1.3; .NET4.0C;
.NET4.0E; InfoPath.2) Timestamp: Sat,
12 Mar 2011 11:31:32 UTC

Message: Expected identifier, string
or number Line: 140 Char: 1 Code: 0
URI:
http://www.itsdaniel0.com/2011/03/unicorns-are-cool/

Message: Object doesn’t support this
property or method Line: 16 Char: 1
Code: 0 URI:
dl.dropbox.com/u/17087195/website/sidebar_size.js

Message: ‘twttr.anywhere._instances’
is null or not an object Line: 1 Char:
5207 Code: 0 URI:
platform.twitter.com/anywhere.js?id=6vIPELyEeU5vcSc3c0Q5w&v=1

Message: ‘twttr.anywhere._instances’
is null or not an object Line: 1 Char:
5207 Code: 0 URI:
platform.twitter.com/anywhere.js?id=6vIPELyEeU5vcSc3c0Q5w&v=1

Removed http from URLs due to “low rep” error

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T17:59:04+00:00Added an answer on May 20, 2026 at 5:59 pm

    OLD ANSWER USING JQUERY:

    //the function to hide the div
    function hideDiv(){
    
        if ($(window).width() < 1024) {
    
                $("#floatdiv").fadeOut("slow");
    
        }else{
    
            $("#floatdiv").fadeIn("slow");
    
        }
    
    }
    
    //run on document load and on window resize
    $(document).ready(function () {
    
        //on load
        hideDiv();
    
        //on resize
        $(window).resize(function(){
            hideDiv();
        });
    
    });
    

    EDIT: Please note that now there is much more cross browser support for css3 media queries it would be much more effective to use those rather than javascript.

    USING CSS.

    /* always assume on smaller screen first */
    
    #floatdiv {
        display:none;
    }
    
    /* if screen size gets wider than 1024 */
    
    @media screen and (min-width:1024px){
        #floatdiv {
            display:block;
        }
    }
    

    Note that in most modern browsers you can also run media queries in javascript using window.matchMedia

    if(window.matchMedia("(min-width:1024px)").matches){
        console.log("window is greater than 1024px wide");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to reproduce the problem from this question , I've found I can't plot
I am using the following code that I originally found from this question: Prevent
Based on some other code I found from this site (This Question here -
I'm trying to parse a html doc using some code I found from this
I found this from C++FAQ Generally, No. From a member function or friend of
I have this code which I have found from google. It's a adapter for
I found this code from here: http://www.cssportal.com/form-elements/text-box.htm But the problem is you can still
I found the code from the net in which i cant understand this line:-
This is from a small library that I found online: const char* GetHandStateBrief(const PostFlopState*
I found something like this in a SqlServer DB stored proc: SELECT stuff FROM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.