1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need Help to Fix this Code

Discussion in 'HTML & JavaScript' started by K.H.R, Jun 22, 2016.

  1. K.H.R

    K.H.R Jr. VIP Jr. VIP

    Joined:
    Dec 9, 2013
    Messages:
    3,154
    Likes Received:
    1,006
    Gender:
    Male
    Location:
    BHW
    Hello,

    I Wrote this html code to Musk a Domain & Reload the Page just for 1 time. But This is not working perfectly, Its Continually Reloading the Page.
    HTML:
    <html>
    <head>
    <title>Test</title>
    <meta name="description" content="Test Description" />
    <meta name="keywords" content="Test, Test 1" />
    <meta http-equiv="refresh" content="10">
    </head>
    <frameset rows="100%,0" border="0">
      <frame src="https://www.test.com" frameborder="0">
      <frame frameborder="0">
    </frameset>
    </html>
    Please Help me to Fix This. I just want to reload the page 1 time.

    Thanks for Helping...
     
  2. dreamsoftware

    dreamsoftware Newbie

    Joined:
    Jun 27, 2014
    Messages:
    30
    Likes Received:
    3
    You need to track it some way, otherwise you end up in a loop forever. Use JS location.reload(true); with GET param to stop it from reloading infinite times :)
     
  3. Conor

    Conor Jr. VIP Jr. VIP

    Joined:
    Nov 7, 2012
    Messages:
    3,544
    Likes Received:
    5,862
    Gender:
    Male
    Location:
    South Africa
    Home Page:
  4. K.H.R

    K.H.R Jr. VIP Jr. VIP

    Joined:
    Dec 9, 2013
    Messages:
    3,154
    Likes Received:
    1,006
    Gender:
    Male
    Location:
    BHW
    Thanks. Can You Please Provide the Full Script?
     
  5. VeeGeeN

    VeeGeeN Regular Member

    Joined:
    Mar 8, 2016
    Messages:
    257
    Likes Received:
    152
    Why not read the web page provided and learn the skills required to fix your problem. Why do people on this forum expect everything hand fed to them?

    You gain some basic JS knowledge and the skills to possibly fix more problems in the future...
     
    • Thanks Thanks x 1
  6. K.H.R

    K.H.R Jr. VIP Jr. VIP

    Joined:
    Dec 9, 2013
    Messages:
    3,154
    Likes Received:
    1,006
    Gender:
    Male
    Location:
    BHW
    Stop Loading Free Advice. People join any Community for Getting Help/Helping People. Not To Free Loading. If you cant help stay away from my post.

    Stop Increasing your post count by S**t. Rather try to help people.

    Hope You Understand.
     
    Last edited: Jun 22, 2016
  7. K.H.R

    K.H.R Jr. VIP Jr. VIP

    Joined:
    Dec 9, 2013
    Messages:
    3,154
    Likes Received:
    1,006
    Gender:
    Male
    Location:
    BHW
    Can any one provide me right code pls.

    Please Help Me
     
  8. Slyeagle

    Slyeagle Newbie

    Joined:
    Jun 22, 2016
    Messages:
    23
    Likes Received:
    3
    Gender:
    Male
    Hi, maybe you could forward it to it self with meta refresh and attach a variable, for example:

    <META http-equiv="refresh" content="1;URL=http://www.index.php?r=y/">

    so your php code would look like:

    <?
    if($_GET[r]=='y'){

    // DO NOTHING

    }else{
    ?>

    <META http-equiv="refresh" content="1;URL=http://www.index.php?r=y/">
    <?
    }
    ?>

    There are several ways but that should do the trick

    hope that helps :)
     
  9. qrazy

    qrazy Senior Member

    Joined:
    Mar 19, 2012
    Messages:
    1,115
    Likes Received:
    1,723
    Location:
    Banana Republic
    There's nothing to fix in the code. As others mentioned, you need to track if the page is refreshed using some variable, session or cookies.
     
  10. K.H.R

    K.H.R Jr. VIP Jr. VIP

    Joined:
    Dec 9, 2013
    Messages:
    3,154
    Likes Received:
    1,006
    Gender:
    Male
    Location:
    BHW
    Thank you so much
     
  11. Slyeagle

    Slyeagle Newbie

    Joined:
    Jun 22, 2016
    Messages:
    23
    Likes Received:
    3
    Gender:
    Male
    You're welcome it would be great to get a profile like as I'm a new member so am trying to build up a trusted profile (although I'm not sure on the etiquette on asking for likes so disregard if that is out of turn.

    if you need anything else let me know

    thanks
     
  12. K.H.R

    K.H.R Jr. VIP Jr. VIP

    Joined:
    Dec 9, 2013
    Messages:
    3,154
    Likes Received:
    1,006
    Gender:
    Male
    Location:
    BHW
    This is forwarding the Domain. But I Need to Musk the Domain.

    Thanks for your Help. But, If you can, Please give me the Right code that I looking for.

    Thanks again
     
  13. Slyeagle

    Slyeagle Newbie

    Joined:
    Jun 22, 2016
    Messages:
    23
    Likes Received:
    3
    Gender:
    Male
    What is it you are trying to do exactly - if you can detail what you need I can maybe come up with the best way to do things.

    Thanks
     
  14. K.H.R

    K.H.R Jr. VIP Jr. VIP

    Joined:
    Dec 9, 2013
    Messages:
    3,154
    Likes Received:
    1,006
    Gender:
    Male
    Location:
    BHW
    Look at my HTML code.
    I want to Mask a Domain, That Means The Original Site will Load under my Domain. Then after 3 second this will refresh only one time.

    My code is working well for masking, But the site refreshing again and again.
     
  15. LuckyDeath

    LuckyDeath Newbie

    Joined:
    Jan 25, 2015
    Messages:
    11
    Likes Received:
    5
    Hello, I've written full code for you:
    HTML:
    <!doctype html>
    <html lang="en">
        <head>
            <meta charset="utf-8">
            <meta name="description" content="">
    
            <title>Reload only once</title>
    
            <script>
                window.onload = function()
                {
                    if( !localStorage.flag )
                    {
                        localStorage.setItem( 'flag', true );
    
                        window.location.reload();
                    }
                }
            </script>
        </head>
    
        <body>
            <frameset rows="100%,0" border="0">
                <frame src="https://www.test.com" frameborder="0">
    
                <frame frameborder="0">
            </frameset>
        </body>
    </html>
    Site will load once, then (after everything is loaded) save to browsers local storage variable "flag" with value of "true", and then make a reload. After one reload will be variable "flag" set, and if so, condition will not be executed.

    EDIT: if you want to reload after some delay, you may use setTimeout - like this:
    Code:
    window.onload = function()
    {
        setTimeout( function()
        {
            if( !localStorage.flag )
            {
                localStorage.setItem( 'flag', true );
    
                window.location.reload();
            }
        }, 3000 );
    }
    EDIT 2: There is one pitfall, unfortenetly - variable is saved in your browser forever (I think). But there is a workaroud:
    HTML:
    window.onload = function()
    {
        if( !localStorage.flag )
        {
            setTimeout( function()
            {
                localStorage.setItem( 'flag', true );
    
                window.location.reload();
            }, 3000 );
        }
        else
        {
            localStorage.removeItem( 'flag' );
        }
    }
    After reload is made (by script), variable is removed. So if you make another refresh or go to your site anytime you want, script will "restart".
     
    • Thanks Thanks x 1
    Last edited: Jun 22, 2016
  16. Ambassy

    Ambassy BANNED BANNED

    Joined:
    Apr 13, 2011
    Messages:
    642
    Likes Received:
    165

    1. Why the fuck did you not post this in your OP?
    Why did 20 people have to dig for you in order to uncover wtf you truly were asking?

    2. Conor literally posted the code you need to use (except the 3 sec delay).

    Here's the script you need to use - it can literally be pasted in your document so even a dumbass like you should be able to do it.

    Code:
    <script>
    setTimeout(function() {
      if (!window.location.hash) {
      window.location = window.location + '#loaded';
      window.location.reload();
      }
    }, 3000);
    </script>
     
    • Thanks Thanks x 1
  17. K.H.R

    K.H.R Jr. VIP Jr. VIP

    Joined:
    Dec 9, 2013
    Messages:
    3,154
    Likes Received:
    1,006
    Gender:
    Male
    Location:
    BHW
    Thank You So Much.
     
  18. LuckyDeath

    LuckyDeath Newbie

    Joined:
    Jan 25, 2015
    Messages:
    11
    Likes Received:
    5
    No problem. Take a look at my edit 2. ;)
     
  19. VeeGeeN

    VeeGeeN Regular Member

    Joined:
    Mar 8, 2016
    Messages:
    257
    Likes Received:
    152
    Oh I understand. You want somebody else to do the work that they already provided the fix for. You aren't learning anything by being spoonfed. You'll use the same code repeatedly for other websites via copy & paste. Whereas you could learn a valuable basic skill set by applying some common sense maybe leading to fixing other basic problems in the future using JS. But, you'll come back here and copy/paste and ask to be fixed for free.

    HOPE YOU UNDERSTAND.
     
  20. K.H.R

    K.H.R Jr. VIP Jr. VIP

    Joined:
    Dec 9, 2013
    Messages:
    3,154
    Likes Received:
    1,006
    Gender:
    Male
    Location:
    BHW
    Finally, I could write my desired script. This will Musk Domain & It will Reload the Page One Time After 1st Load.

    Thanks Everyone.

    Here is the Code:
    HTML:
    <html>
    <head>
    <title>Test</title>
    <meta name="description" content="Test Description" />
    <meta name="keywords" content="Test, Test 1" />
    <?php if(!isset($_GET['p'])) {
    echo '<meta http-equiv="refresh" content= "10;URL=?p=1" />';
    } ?>
    
    </head>
    
    <iframe src="https://test.com/" name="iframeName"></iframe>
    <style>
    body {
        margin: 0;            /* Reset default margin */
    }
    iframe {
    
        border: none;         /* Reset default border */
        height: 100vh;        /* Viewport-relative units */
        width: 100vw;
    }
    </style>
    
    
    </html>