I am new to php. I have Form on a page with a button that once clicked it pops up another sub page :
onclick="newPopup('page2.php','750','500')
page2.php has another button, I want to be able to redirect the Main Page to another url using this pop-up.
How can I do this?
If you want to redirect the main page on a button click in the popup, you need to do this with JS, not PHP.
Add this to the button in the popup:
onclick="window.opener.location.href='someurl.php'";
From a popup, you can access the page/window that opened the popup with: window.opener. This means that you also can call functions on the main page: window.opener.someFunctionOnTheMainPage().
On click of button, you can execute below JavaScript:
window.opener.location.href = 'new URL';
This will redirect your parent page to the new URL.
Related
after click the submit button on my form, how do I add the anchor "#work" in the url without reloading the page?
example: www.test.it/#work
i use header('Location: #work'); but refresh my page.
Update:
I use "jessica" solution:
I think the page is reloaded
But don't work, ca see here: http://www.substellar.it/ftende/contatti/
I think the page is reloaded
Just add #work to the action in form for it to show up in the link.
<form action = "url#work">
Iam just using an iframe for login and register.
and i need to reload the page when the message appears that he successfully registered/logged-in.
for example the iframe would be
when he click login in the iframe it reload other page called "login_success" this page send message"successfully logged in".
Now is the proplem i need the browser reload the page so that the session work in the page that loads the Iframe.
Thanks for responding.
You can use following script.
window.parent.location.reload();
Here it is
document.getElementById('ifarme_id').contentWindow.location.reload();
If it is in same domain you can try below
var myframe = document.getElementById('Ifrme_id');
myframe.src = myframe.src;
I have a page where if you click on a link, it exposes a div that using ajax displays content from a dbase.
After a user edits this content on the server, I'd like to use PHP to return the user to that page. This is no problem using a redirect
header("location:page.php")
However, when the user comes back to the page, ideally, I'd like to have the content in the div open automatically so the user can immediately see edits without having to find the link to open the div and click on it.
Is this possible, either with something in the url to fire the javascript or alternaively, when you load the page with a certain parameter, triggering javascript to open the div.
The code to open the div is a simple javascript call:
View Content
showDiv just uses ajax to display something from the server using responsetext.
Thanks for any suggestions
header("location:page.php?show=1")
Then in page.php body tag:
<body <?php if($_GET['show']==1) { ?>onload="showDiv()"<?php } ?>>
I have listed projects in main work page, If i click on the project it will direct to work page where details have been displayed,If i click on the back button its is redirecting main work page.I want back button should redirect the previous project please help.
For your back button to redirect you to the previous project, you need to change the present HTML from
BACK
to :
BACK
You will have to do this dynamically by calculating the page numbers in the href as $_GET['page'] - 1
<? $page = (int) $_GET['page']; $back = $_GET['page'] - 1;
print 'BACK';
?>
The back button in my browser is working as-designed on your site: it takes me to the previous webpage I was on.
Websites cannot (easily) alter the behaviour of the browser back button in order to keep the user in-control. You can't (easily) use the back button to navigate through a website (if I understand your question correctly).
why not change the back button client-side?
<a href='#' id='backBtn'>Back</a>
And in JS:
document.getElementById('backBtn').onclick = function()
{
history.back();
};
If all you want is for the back btn to behave like the browser back button?
i have simple coding problem. i have created a page with textbox and share button. the page also contains one Points up button.
i had a problem with that points up button that when the user click on that button and refresh the page ... a window ask for resend of information
for that i have used following code which works fine.
`header('Location: samepageurl.php');
exit;`
but the problem with above code is when user scroll down page and click the button. the page automatically scrolls up. and user have to manually scroll it down.
what i want is the page should refresh but it should be on the same location where it was.
if the problem is still unclear please refer the following images
You can set a fragment identifier.
eg:
<a name="points_up"></a> <!-- this needs to be near that button, the page will scroll exactly where the element is -->
and redirect him to:
header('Location: samepageurl.php#points_up');
die;
Mihai answer is correct, but as you said that fragment identifier is not working because each user has points up button, you can pass user id as a fragment identifier and make a hidden(display : none;) <a> tag and pass the user id in front of each user...
Like this:
You can set a prefix before a user id too (optional)
<a name="pu12345" style="display: none;"></a>
<?php
header('Location: whatever.php#pu12345');
exit;
?>
You can send the request via ajax instead relying on the normal form submission. That will not affect the scrolling of the current page.
Add this line at the bottom of your page before the the <\body> tag
<button id="PageRefresh">Refresh a Page in jQuery</button>
<script type="text/javascript">
$('#PageRefresh').click(function() {
location.reload();
});
</script>