I have a website that that suddenly start triggering a new ad window, something that I didn't do myself. I want to know how can I know which part of the page or script is responsible for opening the new window after I click a specific link?
There are a lot of files, so I am searching for a tool that can catch those specific javascript codes that do pop ups. Then I can find the source of the code and neutralize it. I prefer not to do manual search because there are a lot of JS files.
In IE press f12 and start the profiler. It will tell you what javascript has executed so far during your browsing session. I would look at the calls there to narrow it down.
It should be something like
window.open()
In JavaScript
Related
I am trying to profile some javascript code on this url by setting an event listener breakpoint on mouse click.
When you click on any flight on the results page, it opens a new tab with another link and the logic to build that link must be using javascript, since there is no network traffic going on when the click is done.
The problem is when doing a profiling it shows some js functions called but none of them related to the new tab opened. Maybe it is related to some other event? Any other ways to profile this use case?
Basically the goal would be to understand how that new tab link is generated and get it without the need to actually click it, using data that must be already present somewhere on the code beforehand.
Any insights would be appreciated!
I use a userscript to modify the client-side code of a website. This code is adding an anchor tag to the page. Its target is _blank. The thing is that if I click this link too frequently, the site errors. A simple refresh on the new tab fixes the problem.
When I click on the link and it instantly opens a new tab. But I don't want that new tab to render until I visit it, or with some sort of time delay. Is there a way of achieving this?
I am using Firefox, so Firefox-only solutions are fine. I found this, but I don't see a way of using it to prevent the tab from rendering in the first place. When I Google for this, I see results about add-ons that can solve the problem. But, the links to them always 404. Ideally, the solution would only affect the tabs created by this script instead of the way all tabs work, but if the only way to do it is to affect the way all tabs work, I'd accept that as a solution.
The Tampermonkey documentation says there is a GM_openInTab function. It has a parameter called loadInBackground, but it only decides if the new tab is focused when you click the link.
If there is a way of making this new tab render some HTML of my choosing, I think that would be a neat solution. i.e., I'd write some HTML that, on focus, goes to the actual website's page. If this is an option, I'd need to know how to open a tab to HTML of my choosing in grease monkey.
(Just realization of idea you told in your question yourself)
You can place simple page that waits for focus and then redirects to what you pass in URL parameter somewhere and open in background tabs. Like:
load-url-from-search-on-focus.html?http://example.com:
<!doctype html>
<body
onload="document.title=u=location.search.slice(1)"
onfocus="u?document.location.replace(u):document.write('?search missing')">
Try it.
(data:uri could have been used instead of hosted page, if there weren't those pesky security precautions blocking rendering of top-level datauri navigations :|)
I've done some looking around and couldn't find any solution to this problem.
I'm creating a Chrome extension, with a manifest that points to the opening file home-times.html. This works, though I want to redirect it internally to the other page home-welcome.html inside the extension so it loads another page INSIDE the extension.
I've read a lot of questions that refer to changing the current tab's page, though that's not what I am after.
Tests
By using the following code:
test
Opens a new tab, with the extensions page that I am trying to access in that new tab.
If I got you right, you want to change your popup innerHTML, in this case I suggest using jQuery, to change original file to the result you want.
If you just want to open new tab, with your home-welcome.html, you can do this, in your popup.js :
window.open('home-welcome.html','_blank')
If none of this is what you are looking for, can you please provide an example, I will try to help.
I find myself in need of a script to (1) open a link in a new tab and (2) close the current tab so the back button cannot be used to see the website that was previously being viewed. This is a security feature for a site, and unfortunately I'm at a complete loss. Nothing I've tried works and I don't know where to begin. This is likely very simple and is staring me in the face, but I don't normally find myself needing to use java for anything. Any ideas?
Its impossible, but as found in this thread how to stop browser back button using javascript you can prevent users from going back.
Theres a JS bin with an example
Edit - Please bear in mind the warning 'It is generally a bad idea overriding the default behavior of web browser.'
I have a an iframe that has a report within it. What I also have, is a feature to allow the user to detach the report within the iframe and open it up in it's own window, using window.open() call.
My problem is, when I press on the detach button, the whole report that initially loaded in the iframe actually goes through the motions of re-running the query again and so presents the user with a white screen until the report eventually renders again.
Is there anyway of not re-running the report in the detached window or somehow grabbing a cached version?
Thanks.
If you already have the HTML on the client side, you can write that to the popup window without going to the server.
var w = window.open();
w.document.write("Text in new Window");
That will open a window and write some text to it. All you need to do now is get the content from your iframe and write it to the new window. Bingo :)
BTW IMO: Opening new windows in browsers should be avoided where possible as many browsers block it and most automated UI testing tools don't support it.
EDIT (in response to comment):
Here is an example of reading from and writing to an iFrame using the jQuery JavaScript library.
// Write to
$("iframe").contents().find("body").html("Test Html")
// Read from
alert($("iframe").contents().find("body").html());
This basically finds iframe elements in the document and reads and write content to them. If your not using a JavaScript library I highly recommend learning up and using one of them.
BTW: My advice on popup windows also holds for iframes. You should avoid using them where possible.