This question already has answers here:
PHP Header redirect to Multiple URLs with a time gap
(5 answers)
Closed 7 years ago.
I have a link and when the user clicks it, it takes them as follows:
header('Location: www.mysite.com/part2.php');
I would instead like to take the user to part1.php for a couple of seconds before taking them to part2.php. User clicks,
part1.php is visited for a few seconds, then part2.php is visited. part1.php is used as a gateway so it somehow has to know the request came from the link to pass over to part2.php
Is this possible?
This is possible using JS. Put the code below on part1.php
setTimeout(function () {
location.href = 'part2.php';
}, <delay in milliseconds>);
Short answer... no.
Long answer. You will need to issue the redirect in part 1 to redirect then to page 2. You can do so using the meta redirect tag, or using a javascript timer on page 1, so that page 1 is visible on the browser before the page 2 appears.
See here for how to use meta refresh...https://en.m.wikipedia.org/wiki/Meta_refresh
Related
This question already has answers here:
How to keep the changes made to DOM by javascript/jquery on page refresh
(2 answers)
How to get JS variable to retain value after page refresh? [duplicate]
(4 answers)
Closed 1 year ago.
Is it possible to save dynamically added HTML elements with JavaScript on HTML page? For example, when I create some HTML element (div, p, li...) using JavaScript, then add it on a page, it appears on the page as it should be, but as soon as I reload or leave the page, and then get back - all those elements disappear. So, how can I do so that they do not disappear after reloading or leaving page (If such is possible).
It is not possible without some backend interaction. But if you need it only for one client (one browser) you can store some details to localStorage and use it on the next load. You have to be aware only one client will be able to see it.
This question already has answers here:
How to capture the browser window close event?
(17 answers)
Closed 4 years ago.
I want to check my registers users active or not for that users came to my index.php page i want to insert the table through session user1 is active and same time without logout user1 is closing the browser tab or browser the table should be update user1 is inactive.
Advice me it's possible to do that, can do mean please help me how to do that part or is there any possible way to do that same function.
Yes, it is quite easy to implement this. You can make an AJAX call on onbeforeunload() and then handle that AJAX request and update the status of the user in the table. You can get the user from SESSION[] array.
You can use onbeforeunload event handler in Javascript.
More details here
var inFormOrLink;
$(window).bind("beforeunload", function() {
return inFormOrLink ? "Do you really want to close?" : null;
})
this code is working but this message is not coming ('Changes you made may not be saved') this message only coming why is that?
This question already has answers here:
Javascript onclick function is called immediately (not when clicked)? [duplicate]
(1 answer)
Why is this javascript function running without being called?
(4 answers)
Javasctipt function running without being called? [duplicate]
(1 answer)
Closed 4 years ago.
The code is supposed to redirect the user to another internal page. However when the page loads with the code in it it automatically redirects the user without the user having to click the button.
I'm pretty new. I don't know what to try. I think it should work as is.
document.querySelector(".choice").addEventListener('apple', Redirect());
function Redirect()
{
window.location = "challenge.html";
}
The expected result is that the user would click the text that contain the choice class and it would redirect the user to the challenge page.
The actual result is when the page loads it automatically redirects the user to the challenge page without the user having to click the button.
You are invoking the event handler in this line:
document.querySelector(".choice").addEventListener('apple', Redirect());
Remove the parentheses:
document.querySelector(".choice").addEventListener('apple', Redirect);
You need to pass a reference to addEventListener otherwise with your current setup not only will the user be redirected immediately after the listener is registered, the button will also do nothing because the Redirect function is not returning something
This question already has answers here:
Check if event is triggered by a human
(9 answers)
Closed 4 years ago.
I have some images that are clickable. for each click , users can get some point.
But I want to prevent clicks that do by bots. in fact I want a way to detect that a real user is clicked or a bot.
I want do that in javascript or jquery. if anyone know a plugin that can do that Please introduce me to it.
You can simply assume it’s human, provided access to the page is protected by reCAPTCHA, and subsequent requests carry a CSRF token.
This question already has answers here:
Remove http referer
(10 answers)
Hide Referrer on click
(8 answers)
Is it possible to remove the referrer in PHP before redirected?
(5 answers)
Closed 5 years ago.
I am working on a web with php (laravel 5.4) and I have to generate several links that the user clicking on them does not let you know that the click originated from my web page. The idea is that it seems that the user wrote the link directly in the browser, and that does not relate in any way that clicked from my website. how can I do it? Thanks for your help.
You can do that using javaScript. You need to define a function that accepts a url as parameter and calls the javascript window.open().
Make a regular tag and in its href attribute pass javascript:void(0); so that the default link click action is stopped.
Now define an attribute onClick and call your defined function here and pass the url you want to open.
Please see the example below:
<script type="text/javascript">
function openURL(url)
{
window.open(url);
}
</script>
GOOGLE