How to stop page load in html static page

后端 未结 11 1300
庸人自扰
庸人自扰 2020-11-30 02:35

Is there in HTML (javascript) or other static html tech can:

  • Stop page loading (if browser does not download yet)
  • Stop page rendering (from where the
相关标签:
11条回答
  • What you are asking makes no logical sense. Simply for two reasons:

    • Data is ALREADY sent to the user (HTML / JS) so even tho if you COULD hide content, the data would sitll be there for a user to see (if they view source for instance).
    • Why would you stop 'execution' of a page? It loads simple html structure and reults in a visual display, you should focus on the server site (php for instance) to hide or not send the content in the first place.

    If you want to visually hide elements tho, you could use CSS styles (hide divs or the like) with simply adding style="display:none;" to a div like so:

    <div style="display:none;">
    This text will be downloaded by the user, but hidden from view due to CSS inline style
    </div>
    

    If you want to add commenting (thats just for your reference), then use comment formatting:

    <!-- this is a comment and will not show up to a user -->
    

    Reference for comments: http://htmlhelp.com/reference/wilbur/misc/comment.html

    0 讨论(0)
  • 2020-11-30 03:06

    The stop methods can break things that have already started to load.

    If you want to load everything above a certain point and skip everything below a certain point:

    <p>Everything works above this point.</p>
    <pre style="display: none !important;">
    <p>As long as the PRE tag remains open, 
    nothing works below this point</p>
    <script>document.write('Nope');
    
    0 讨论(0)
  • 2020-11-30 03:10

    If you are using ASP or PHP, HTTP protocol automatically stops but HTTPS protocol don't stop automatically.

    To stop it use:

    In ASP:

    dim r= accept.secure.protocol
    r.onload=window.callback('c')
    
    //to firefox,opera,safari
    
    new clientObject(r).access()
    // to chrome,ie
    
    forEachElement(a==null);
    

    PHP code:

    $a.window ;
    

    All this scripts sends the browserstring "elementcast" by post method

    0 讨论(0)
  • 2020-11-30 03:11

    If you already have html comments on your page, @bukko's solution doesn't fully work. Stuff after the html comment will get rendered normally.

    Something else to try is:

    document.write('<script type="text/undefined">')
    

    The rest of the document gets interpreted as part of the script tag, and because the script isn't text/javascript, it gets ignored.

    Worked for me, thought I'd share it.


    Edit

    I've seen the script trick not work in Chrome.

    This does work, but I have not done extensive browser testing:

    document.write('<style type="text/undefined">')
    
    0 讨论(0)
  • 2020-11-30 03:12

    You could do window.stop(); for most browsers besides Internet Explorer. For IE, I had to use document.execCommand('Stop');

    0 讨论(0)
提交回复
热议问题