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 7414169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:01:13+00:00 2026-05-29T07:01:13+00:00

One of the scripts to an offsite third party widget broke during execution and

  • 0

One of the scripts to an offsite third party widget broke during execution and redirected all traffic on my homepage to theirs.

Since I can’t kill them, I’m either going to have to kill the script, or figure out a way to kill any attempt a third party JavaScript might make to redirect the browser. The most promising events I’ve found are .unload() and window.onbeforeunload, and my idea is to hopefully inspect the GET request and then validate the URL as not matching any of the valid links on my page, that’s no problem except that I don’t know how to get the event’s GET value considering it’s not bound to any clicks or action on the page, but a bogus something or other in a third party’s .js?

Anybody have luck working out a solution to something like this?

  • 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-29T07:01:15+00:00Added an answer on May 29, 2026 at 7:01 am

    There is no way that I know of to intercept all possible places that 3rd party javascript might set window.location causing a redirection and preflight it. It is not a method, it’s just a property set to there’s no method to replace/override.

    The page unload event just gives you a chance to ask the user if they really want to leave this page, but it has no access to what the new page destination is.

    The only thing I can think of is to keep a global variable that contains a boolean that defaults to false. In all possible places that you might change pages in your own code, you set that boolean to true. In the onbeforeunload handler, you check that global variable to see whether it’s something your code did or not. If it is not something your code did, you return a message from onbeforeunload so the user will be prompted for whether they really want to leave or not. But, you can’t prevent it (this is a browser design on purpose). If they say yes to the prompt, they will leave the page to the new destination.

    If you or someone else could actually figure out why the 3rd party was inintentionally causing the redirection, then perhaps you could concentrate on making sure that condition doesn’t happen again, but you’ve given us no info on that so we can’t really help with that.

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

Sidebar

Related Questions

I typically put all the JavaScript scripts into one file e.g. scripts.js (the less
I am using one master page.In that I am registering java scripts and checking
Just wondering what little scripts/programs people here have written that helps one with his
I'm trying to figure out why one of our migration scripts is taking forever
I'm writing some db utility scripts, and one of the tasks I need to
With my database upgrade scripts, I typically just have one long script that makes
I have two scripts running on the same page, one is the jQuery.hSlides.js script
Which of the following registry scripts is syntactically correct? Will both work? Is one
I have a one page web application, which means alot of javascript. External scripts
I'm trying to replace a bunch of Linux shell scripts with Scala scripts. One

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.