Need Help to Fix this Code

KHR

Elite Member
Jr. VIP
Joined
Dec 9, 2013
Messages
4,700
Reaction score
1,635
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...
 
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 :)
 
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 :)
Thanks. Can You Please Provide the Full Script?
 
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...
 
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...
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:
Can any one provide me right code pls.

Please Help Me
 
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 :)
 
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.
 
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 :)
Thank you so much
 
Thank you so much
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
 
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
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
 
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

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
 
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
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.
 
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".
 
Last edited:
  • Like
Reactions: KHR
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.


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>
 
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 );
}
Thank You So Much.
 
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.

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.
 
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>
 
Back
Top