Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.open titlebar

Status
Not open for further replies.

KryptoS

Programmer
Feb 7, 2001
240
BE
Hey,

I want to open an image in a popup. So I got this:

<a href="javascript:showImage('test.jpg'">

<script language="javascript">
function showImage(URL) {
window.open(URL,'This is my picture','fullscreen=no...');
}
</script>


But in the popup I always get as title ... But I don't want that, I want something like 'This is my picture'.

can someone help me with this?

greetz

The One And Only KryptoS
 
Make the <title> on the page you want to open whatever you want it to be.

Lee
 
Using your code, you can dynamically change the opened window title like this:
Code:
<script type="text/javascript">
function showImage(URL, title)
{
var newwindow = window.open(URL,'newwindow','fullscreen=no...');
newwindow.document.title = title;
}          
</script>

Lee
 
Hey,

me back again :).

I did it like trollacious said in his second post. (I can't use <title> in my popup window)

But the problem is that when I click the link, it show a pop-up still with When I close the window and click again then still don't get my title.
But when I click to open the popup. And click a second time on the link (without closing the popup) then it gets the title 'my photo'.

So it works, but only if I click 2 times the link? :s

anyone who can help me with this?

The One And Only KryptoS
 
this is what the code looks like when I look at the source in internet explorer:

<a href="javascript:showImage('imageloader.php?id=273')"><img src=imageloader.php?id=273 width=50 height=50 border=0></a>
<script language="javascript">
function showImage(URL) {
newwindow =window.open(URL, null,"toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=yes,fullscreen=no,width=300,height=300");
newwindow.document.title = "my photo";
}

The One And Only KryptoS
 
Since you're using PHP, why don't you pass the title tot he new page in the URL and write it with PHP?

Lee
 
the problem is that I can't write anything in the imageloader.php (the popup).

this is the code of the imageloader, I just get the image out off a table and print it:

$result = mysql_query(sprintf("SELECT * from tbl_e_images WHERE ImageId = %d", $_GET['id']));
$row = mysql_fetch_array($result);
header(sprintf("Content-type: %s", $row['FileType']));
print $row['Image'];

the problem I get when I do something like <title> (or whatever text I do in the imageloader-file) is this:

Warning: Cannot modify header information - headers already sent by (output started at d:\Wamp\ in d:\Wamp\ on line 6


The One And Only KryptoS
 
I finnaly discoverd the problem. But I still don't have the solution...

I use :

newwindow =window.open(URL,null, "toolbar=no bla bla");
newwindow.document.title = "my photo";

This sets the title of my popup. The problem is that most of the time the line newwindow.document.title is excecuted before the popup window is open.
So I need to delay the excecution of the second line so that I'm sure that the popup window is open.

any suggestions?

The One And Only KryptoS
 
Sorry about not getting back to you sooner. I found the same thing. You might try something like this:
Code:
newwindow.onload = 'newwindow.document.title = "my photo"';

BillyRayPreachersSon had a great idea to add things to the onload event handler in a recent thread, so you might click on his name on the right and check his responses for the past 10 days or so.

Lee
 
thanks for the information... I'm now using a setTimeout

something like this:

newwindow =window.open(URL,null, "toolbar=no bla bla");
k = setTimeout('setTitle()',100);
function setTitle() {
newwindow.document.title = "my photo";
}


The One And Only KryptoS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top