Click here to Skip to main content
15,740,620 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,I am using php first time, i want to open image in image viewer instead of browser by using javascript only. please help...
here i wrote down what i tried

What I have tried:

this is html code in Php page

echo "<div style = 'text-align:center;width:200px;'>"	;
				echo "<div height = '175px;'>";
				echo "<img  src='..".$row["FilePath"]."/".$row["FileName"]."' width ='200px' height = '175px' style ='float:left;' onclick='image(this)' ></img>";
				echo "</div>";
				echo "<p width = '200px'> ".$row["filetitle"]." </p>";
				echo "</div>";
				echo "</td>";



and this is javascript function which open image in new tab

<script type="text/javascript">
function image(img) {
    var src = img.src;
	window.open(src);
	
	
}
</script>


but i want open image in image viewer please help
Posted
Updated 12-Dec-17 1:37am
Comments
phil.o 12-Dec-17 3:28am    
It's up to the user to decide which application should handle any file type, not to the developper of the website.
yogeshysankar 12-Dec-17 4:14am    
there are only image files in database which i retrive .. i just want to open image like modal using java script
Richard Deeming 13-Dec-17 11:19am    
Are you looking for something like Lightbox[^]?
Mohibur Rashid 12-Dec-17 20:49pm    
how would that be beneficial?

1 solution

There is no method to tell a browser that it should open images (or any other kind of media) with an external application.

The reason is that the user's preferences should be respected and - more important - that such would be prone to security vulnerabilities.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900