Jump to content

onClick inside img tag won't work on IE--help please


geekisthenewsexy

Recommended Posts

hi there guys, i am currently working on this code and was wondering why it won't work on IE and only on FF..my FF's version is 3.6.8 and version 7 on IE..

 

here is the code i am working on

<img src="images/magnifier.png" alt="View rooms" width="16" height="16" onClick="window.open(\'viewroom.php?course='.$row['c_name'].'&year='.$row['year'].'&id='.$row['b_id'].'&block='.$row['block'].'\',\'View rooms\',\'width=350, height=200, menubar=yes\')"/>

 

i don't know if it's okay to put the onclick inside this img tag but so far, it's okay and works on FF..

now what's confusing for me is all the img tags like this one doesn't seem to work in FF except for delete which works both on my FF and IE

 

here's the code

<img src="images/del.png" alt="Delete rooms" width="16" height="16" href="delete.php?course='. $row['c_name'].'" onClick="return confirm(\'You are about to delete this record! Delete?\');"/>

 

okay, if you think it's lacking ; i've already tried that but it still won't work. i hope you guys can help.. :-\

Looks like you're escaping single-quotes. Are you using PHP to deliver this, or is this as it renders in html? I'd want to see the unescaped finished html to make sure there aren't any syntax errors.

 

Also, why not just use an <a> tag and just include "return false;" after your window.open()? Also, in most modern non-quirks mode html, I believe onclick is all lowercase - although most browsers probably won't hold you to it.

 

<a href="somelink.html" onclick="window.open(this.href,'_blank'); return false;"><img src="whatever.jpg" alt="" /></a>

hi there, thanks for the response michaellunsford. :)

yup, i'm using php on this one.

i have already placed it inside the <a> tag like you said. i just didn't do it in the first place because i didn't like having a border on the image, but it's okay now. all it took was border="0". :D

Also, why not just use an <a> tag and just include "return false;" after your window.open()?

 

that's the funny thing, i did that already and it still won't work..

here's the complete code of the images

 

view rooms

<a href="#" onClick="window.open(\'viewroom.php?id='.$row['b_id'].'&block='.$row['block'].'\',\'View rooms\',\'width=350, height=350, menubar=yes\'); return false;"><img src="images/magnifier.png" width="16" height="16" border="0" alt="View rooms" ></a>

 

add rooms

<a href="#" onClick="window.open(\'room.php?id='.$row['b_id'].'&block='.$row['block'].'\',\'Add rooms\',\'width=300, height=300, menubar=yes\'); return false;"><img src="images/add.png" width="16" height="16" border="0" alt="Add rooms"></a>

 

edit

<a href="#" onClick="window.open(\'edit.php?course='.$row['c_name'].'&year='.$row['year'].'&id='.$row['b_id'].'&block='.$row['block'].'\',\'Edit\',\'width=500, height=250, menubar=yes\'); return false;"><img src="images/edit.png" alt="Edit block" width="16" height="16" border="0"></a>

 

delete

<a href="delete.php?course='.$row['c_name'].'&year='.$row['year'].'&block='.$row['block'].'" onClick="return confirm(\'You are about to delete course='.$row['c_name'].' year='.$row['year'].' block='.$row['block'].'! Delete?\'); return false;"><img src="images/del.png" width="16" height="16" border="0" alt="Delete record"></a>

 

there..i've placed this inside the php echo by the way..

 

 

oh okay,sorry for that..

here

echo '<td align="center"><div id="imagealign">
            	<div><a href="#" onClick="window.open(\'viewroom.php?id='.$row['b_id'].'&block='.$row['block'].'\',\'View rooms\',\'width=350, height=350, menubar=yes\');return false;"><img src="images/magnifier.png" alt="View rooms" width="16" height="16" border="0"></a> <a href="#" onClick="window.open(\'room.php?id='.$row['b_id'].'&block='.$row['block'].'\',\'Add rooms\',\'width=300, height=300, menubar=yes\'); return false;"><img src="images/add.png"  alt="Add rooms" width="16" height="16" border="0"></a> | <a href="#" onClick="window.open(\'edit.php?c_id='.$row['c_id'].'&course='.$row['c_name'].'&y_id='.$row['y_id'].'&year='.$row['year'].'&id='.$row['b_id'].'&block='.$row['block'].'\',\'Edit\',\'width=500, height=200, menubar=yes\');return false;"><img src="images/edit.png" alt="Edit block" width="16" height="16" border="0"></a> <a href="delete.php?c_id='.$row['c_id'].'&course='.$row['c_name'].'&y_id='.$row['y_id'].'&year='.$row['year'].'&b_id='.$row['b_id'].'&block='.$row['block'].'" onClick="return confirm(\'You are about to delete '.$row['c_name'].', '.$row['year'].', '.$row['block'].'! Delete?\');return false;"><img src="images/del.png" width="16" height="16" border="0" alt="Delete record"></a></div></div></td>';
	echo "</tr>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.