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

  • Home
  • SEARCH
  • 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 3879096
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:41:15+00:00 2026-05-19T22:41:15+00:00

I have a form on my 404 page that is auto filled with the

  • 0

I have a form on my 404 page that is auto filled with the address the user tried to find. I also have javascript that then auto submits that form.

The problem is, once it auto submits it keeps looping and the page keeps reloading.

I am trying to wright the javascript code to fire once and then stop.
The script fires on page load so that’s whats causing the loop.

Outcome: I need it to fire on page load, page reloads, the code checks to see if its already reloaded once then stops.

For my test I am trying to make it pop an alert that says “I reloaded once” just so I know its worked.

This is my code so far

<script type="text/javascript">
window.onload = function() { 
var grabedurl = window.location.href
document.getElementById('badurl').value=grabedurl;
if( history.previous != history.current ){alert('I reloaded once')}
else
setTimeout("document.getElementById('errorsubmit').click()", 3000);}
</script>
  • 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-19T22:41:15+00:00Added an answer on May 19, 2026 at 10:41 pm

    What you can do is add the state of the page already having been reloaded or not to the query string part of the URL. This should be done in your form‘s action, e.g. action="?submitted"

    window.onload = function()
    { 
        var form = document.getElementById("aspnetForm");
        form.setAttribute("action", form.getAttribute("action") + "&submitted");
        var grabedurl = window.location.href;
        document.getElementById('badurl').value = grabedurl;
        if (/submitted/.test(window.location.search.substring(1)))
        {
            alert('I reloaded once');
        }
        else
        {
            setTimeout("document.getElementById('errorsubmit').click()", 3000);
        }
    }
    

    However, you might want to consider alternative approaches — such as submitting the form via an XMLHttpRequest; having another, separate action page to submit the form to, or having the server log the request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have form where user submits field. Field can have letters, numbers, and punctuation.
i have form with user data to input and javascript ajax to send information
I have a working contact form in Joomla however when the user submits the
I have this page :8000/edit/6/ that show a form to update an exciting model
I have a node.js app that loads a signup form when visiting localhost/user/signup: html
I have created a basic contact form, and when the user submits information, it
I have form where are 2 input fields and then i have dynamic dataTables
I have form in my page, I am using ajax.beginform(). Inside this form I
I have a web application that have standard form authentication declared, like this: <login-config>
When mapping an Exception to 404 page, the Spring Security tags can't find the

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.