Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    changing image FIREfox issue

    Hi,

    The goal:
    A user selects an image fil on his pc true an input file field.
    A javascript function display's a preview on it next to the file field (without actually oploading the file)

    The RPoblem:
    I used a JS before but it's not Firefox compatibel so I'm trying to fix it

    old JS:
    Code:
    <script language="Javascript" type="text/javascript">
    	 
         function setImage1(string){
              document.getElementById('previewfoto1').src = 'File:\/\/' + string;
    }
            </script>
    What I got now but doesnt work
    Code:
    <script type="text/javascript" language="javascript">
    	function setImage(string)
    	{
    	var image =document.getElementById('previewfoto1').
    	image.Setatrribute('src','File:\/\/'+ string);
    	
    	//also tried this
    	image.src='File:\/\/'+ string';
    	}
    </script>
    the script is called like this:
    <input type="file" name="foto'.$i.'" id="foto'.$i.'"onchange="setImage(this.value);"></span>
    <span class="right"><img width="50" id="previewfoto1" src="../images/site/tableft.gif" alt="preview" ></span>';
    Regards
    Geert

  • #2
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    I can't get Gecko to use the file:// protocol with an image src. Could be a security feature.
    Last edited by hemebond; 03-04-2005 at 10:00 PM.
    Forget style. Code to semantics. Seperate style from structure, and structure from behaviour.
    I code to specs, and test only in Firefox (unless stated otherwise).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •