Cross browser compatibility issues with image preview script

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
drayarms
Forum Contributor
Posts: 134
Joined: Fri Dec 31, 2010 5:11 pm

Cross browser compatibility issues with image preview script

Post by drayarms »

Code: Select all

	

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML1.0 Transitional//EN"



"http//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 


<html xmlns="http://www.w3.org/1999/xhtml"> 


	<head> 

		<script type = "text/javascript" src="http://code.jquery.com/jquery-latest.js"> </script>


		<script type="text/javascript">

        		function readURL(input) {

            			if (input.files && input.files[0]) {

                			var reader = new FileReader();

                			reader.onload = function (e) {

                    				$('#blah').attr('src', e.target.result);

                			}

                			reader.readAsDataURL(input.files[0]);

            			}

        		}

    		</script>



	</head>


	<body>


		<form id="form1" runat="server" enctype="multipart/form-data">

        		<input type='file' onchange="readURL(this);" />

        		<img id="blah" src="#" width = "300px" max-height = "340px" alt="your image" />

    		</form>


	</body>



</html>

User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Cross browser compatibility issues with image preview sc

Post by pickle »

[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2.1. When asking a question, be as specific as you can be, provide the relevant code and any other information that is helpful in a concise and coherent manner. If you are not sure how to do that, read these guidelines.
Posting no context will get you absolutely no help.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply