Click button and after refresh click button from new page - javascript

Im trying to make a script for a game. Where I have to make just 2 clicks, but they are on different pages.
On page 1 I click on "Send"
javascript:document.getElementById('send').click();
When i click on that button, my page redirect to a "confirm" page. Where i need to click "Ok" button.
How can i do to click my first button and after redirect "auto click" the "Ok" button from the new page?

If you also own the second page, you can have the window.onload method check against the url, for example look for the query string ?clickthrough=true (which your first page redirects to) and if it exists simulate a click of the button.
E.g., first page redirects to /second?clickthrough=true, and your javascript on the second page checks the url like this:
if (window.location.href.split("?").slice(-1)[0] == "clickthrough=true")
// click the button
If you do not own the second page, then I'd hope there is no way to do this as it would suddenly open users to a whole host of vulnerabilities.

Related

How do I get the URL of a pop-up so it opens automatically?

There is a button called "Leave a Tip" on a webpage. When the user clicks that button, a pop-up appears asking them to enter the tip they want to leave.
I want a way to bypass having to click on the button in order to get the pop-up to appear.
Is there a way a customer can click on a link that takes them to the page where the pop-up automatically displays (and they don't have to scroll down the page to find the button and click on it)?

Is it possible to know if the user made the call after clicking tel link?

I'm trying to make something like. When a user clicks on a tel link it will open the call screen. And after the user make the call it will redirect the user to a thank you page. By far I've done this.
$(".call").click(function(){
event.preventDefault();
window.open("tel:phone_number");
window.location.href = "thank_you_page.php";
});
By using the above codes, I almost achieved what I wanted. When the user click on the tel link it opens the call screen and also redirect them to the thank you page. But I want the user to be redirected only if the user make the call. If the user cancel the call screen or doesn't make the call, then it is not appropriate to redirect him/her to a thank you page.
Is it possible to know the user action and achieve what I described above?
And one more thing, on Desktop it opens the call alert box to a new tab with blank page.
And the blank page stays even after closing the alert box. I have to close the tab manually.
I tried window.open("tel:phone_number","_self"); but it doesn't open the Call Alert Box at all, but redirects to the thank you page.
How to make the Call Alert Box open in the same page, like it does when the tel link is used in html anchor tag <a href="tel:number"> like this?

submitting a POST form calls my document.ready() function again?

I have an index.php page which imports a "myjs.js" file which includes a document.ready() function. Inside the document.ready() function, I show the home tab by calling .hide(); on all the divs that represent the other tabs. I also have the code so that when i click on a tab, it hides the current div and shows the div that goes with the clicked tab.
one of the tabs that I have is the profile tab, where I have a POST form with a submit button. When I click the submit button, the page goes back to the home tab (exactly the same way as when I go to the page initially). Is there a way from preventing this from happening? The submit button corresponds to some php that i have at the top of my index.php page but I don't want to leave the profile tab when I click the button :(.
Thanks!
EDIT:
actually, you can log on and see for yourselves, the code is live here: www.aaemexico.com/login.php
use credentials:
username: asdf
password: asdf
go to "perfil" tab and choose a new password (change it to asdf so that others can still access it) and click the button. preferably, i would like to not go back to the home tab after i click the button
It sounds like the form is being submitted and the page is posting. You could probably override the submit function and prevent default events to prevent the document.ready from firing again.
Or, in your document.ready, check if the page is already loaded and don't do anything if it is.

Javascript Back Button in Modal - Stop it from closing the modal

How do I get the "back" button seen in my demo to NOT close the modal window?
If this can't be prevented, then at least provide them with a confirmation box alerting them the window is trying to close and ask them if they want to continue.
I'm using a javascript back button link and forward button link to control the user's history inside a modal/lightbox window.
Here's a demo of what is happening... When you begin, the second page will have a link to the modal window, so click that, then click the "back" button in the window as it will take you BACK to the start page. That's the issue I'm having as I don't want this to happen.
http://www.apus.edu/_test/evan/modal/start.htm
Back Button
Foward Button
If you can see where they are in the page (ie: the start page having a static back / forward button ) why not just make the back button a javascript:void(0)? If you aren't going to have a defined front location, use server side to store their start place, and once they have reached it, disable the back option.

Prevent browser's back button from reopening pop up window on previous page

How would I prevent the browser from opening the pop up window that was displayed from the previous page when the user clicks the back button?
I hope that made sense but I'll explain it in point form below:
There are three pages: Page1, Page2, Page3
User loads Page1 and clicks a link to load Page2 in a new window using JavaScript (i.e. window.open(...)). The User can close Page2 anytime they wish-- but we'll assume the user does so before step 2.
User now clicks a link on Page1 to load Page3.
User is now on Page3 and clicks the back button on their browser.
Page1 is displayed in the browser but Page2 is displayed again in a pop up window.
So, I'm wondering if there is a way to prevent Page2 from popping up again. I am using classic ASP as well, if it matters.
If Page2 is opened as a result of clicking a link, how is it automatically being opened when the back button is clicked? Unless Page2 is opened automatically on the initial load of Page1, it shouldn't pop up due to the back button being pressed - pressing "Back" doesn't click a link on the previous page. I suspect something else is going on in your page - can we see some code please?
you can try creating a session variable on page2. and check if it exist upon opening of page1. or use a cookie.
EDIT:
Function IsPostBack()
IsPostBack = (Request.ServerVariables("REQUEST_METHOD") = "POST")
End Function
this will not detect a page refresh though..
The page was redirecting to itself and inserting the javascript code to pop up a new window based on the button pressed previously. I think it determined this via the post or get methods. I forget now.
As such, when the user presses the back button, they will reload the page with the embedded javascript code and not the original page.
We've since left classic ASP behind so I can't really test any suggestions but appreciate the help.

Categories