I need your quick help.
In my web site I have a list of clients with links to their user details.
I used
window.open();return false;
and this opens each profile in new window.
now in the new opening window I have link, which I want to open in another new window/
I tried
window.opener.open();return false;
but it opened in this same window.
How can it be opened in another new window(FF,explorer)??.
I want also to use the above code with Ajax, in my search page.
The problem is, that it also not opening the new window because the link located in the Ajax. how can i open links from Ajax in new window??
Any ideas?
Thanks!!!
Well you can access window.parent from your window object and call a function that will open another window
Use Window.open() in the opened window.
So you have : (1) Page with a link -> (2) opens a popup with a link -> (3) opens another popup
Every link which has to open a popup will call the javascript function window.open. As #Sushil pointed out, if the new window has to look like a regular popup, set width and height to it.
If you want to implement the popups using AJax, use jQuery. Here is a very good example for a simple popup implementation.
Providing height and width to open. this will make sure that new window always open as popup.
window.open(url, 'name', "height=500,width=700"); return false;
Related
I know that there are at least two other similar questions, but they do not help me.
I have textarea with tinymce where user writes his text. Then there is a button "PDF" that should create pdf and open it in new tab. The content of pdf is the content in tinymce.
When user click on button, the form is submitted to index.php action. Then index.php gathers information from $_POST variable and creates pdf.
I cannot get it to open in new tab as a normal link.
I tried it in different ways.
1) I can open PDF in the same tab, but this is not what I need. This line opens my pdf on the same tab:
$dompdf->stream('document.pdf',array('Attachment'=>0));
2) I can open it in new window, but then browser warns that this is pop-up. Client doesn't want it. Also another problem with this is that pdf is stored on server. I do not want it (pop-up warning is more important). Here is my code:
$output = $dompdf->output();
file_put_contents('document.pdf', $output); //save pdf on server
//opens generated pdf in new window, but this creates warning for popup
echo '<script type="text/javascript" language="javascript">
window.open("http://modeles-de-lettres.org/test/saved_pdf.pdf", "_blank");
</script>';
I have read those:
1) Open PDF in a new tab using dompdf
This suggests: "As far as opening in a new tab. That depends on how you are generating the PDF. But the simplest way it to provide a link with a target attribute." I think this means that I have
<a href="my.pdf" target="blank"
or
<a href="my.php" target="blank"
But this does not work for me, because I should POST my form to get data from pdf.
2) generate the pdf on newtab in dompdf
This is something that I have implemented before (I did it without sessions), but it creats warning about popups.
You can simply do the following:
<button type="submit" formtarget="_blank">Submit to a new window</button>
formtarget="_blank" attribute will open new tab.
Hope it will help you!
The problem is the order in which you're doing things. You should be opening the new window from a user event, like clicking a button. If a script on a page load event tries to open a window, the browser will presume it's an unwanted popup, since the user hasn't done anything besides navigating to the page.
What could work for you, is adding a target="somewhere_new" attribute to your form tag. This way, the browser would open a new tab since there's no frame/iframe with a name="somewhere_new" attribute, and you wouldn't have to do anything special in the server side, just process the data as you did before using $dompdf->stream('document.pdf',array('Attachment'=>0)); at the end
I have a php page that opens a pop window. it contains the search results. each result is inside the anchor tags.
I can open a new tab containing the information in the parent window, but somehow the OnClick function does not work. what i want to do is when the user select a link, will open a new tab then the pop up window automatically close. I dont know why the OnClick event is not doing what I want.
<?php
<a href='edit.php?id=$id' target='_blank' onClick='self.close();'>Listq</a>
?>
the code above works but it closes the pop up before opening the new tab. please help. thanks.
Try to close the popup from the new tab on load and not from the popup:
window.opener.close();
Try this:
onClick='setTimeout("self.close();",1)'
Check out this
Close
function closeWin()
{
self.close();
}
You can try onmouseup in stead of onclick. And if that fails too you can also do the opening of the popup in the onclick with window.open(). That way your order is maintained.
So it would look like:
Listq
And get writ of the <?php and ?> tag, or put the anchor in an echo if this is PHP.
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 } ?>>
In codeigniter application i pop up a window from a view page using href link.In that pop up window there have a button to close window after done process.
I want to refresh the view page after closing the pop up window when i clicking on the button in the pop up window.How can i do that?Is there any way to solve my issue
Have the close button call this javascript:
if ( window.opener && !window.opener.closed ) {
window.opener.location.reload();
}
This will test that the opening window exists and is not closed, and then try to reload it.
You could also access other functions or variables using window.opener if you wanted to call some other function, or make it a little more dynamic by only changing one part of the page.
Is it possible to open a window from PHP that has predefined content? It's obvious how you can open a window from a javascript link that frames an existing page, or just do a target=_blank from a regular a tag that references an existing page. But I am generating a bit of content, and want that content to be opened in a new link (or streamed to the viewer)--
something like (clearly psuedo code!):
$content = "Hello World. <br />Nice to meet you!";
<a href="#" target="_blank" content=$content>Open up!</a>
Is this possible?
Thanks!
Well, the direct answer to your question is that you can't really do it from PHP directly, because it's the browser that's going to open the window. You can, however, have your page open a window, get the document object, and write to it:
var w = window.open("Surprise", "#");
var d = w.document.open();
d.write("<!DOCTYPE html><html><body>Hello World</body></html>");
d.close();
Instead of the simple string "Hello World" of course your PHP script can put together whatever it wants. Additionally, if desired, the Javascript code itself can dynamically generate the content based on page status, form fields, etc.
Note that you can't guarantee that the new window won't be a new tab, which is no different than what happens with "target" in <a> or <form> tags.
edit — oh also: if you try to use window.open outside of code that's running in response to a "click", browsers will probably think you're trying to show a pop-up ad and will block it.