[Javascript] xp sp2 ie help
Roger Roelofs
rer at datacompusa.com
Thu Oct 7 07:35:17 CDT 2004
Flavio and other list members,
On Oct 5, 2004, at 11:57 AM, Flavio Gomes wrote:
> Roger,
>
> My idea would be a bit different, it's just a guess (got no IE6.SP2
> to try), but may work.
> I got some "acess denied" when trying to mess with "crossdomain"
> scripting, and as JScript is crazy, probably now it's saying "access
> denied" because "file://" is a different domain from yours site's
> domain. Try something like this:
>
> ===============
> <script>
> function previewImage(oImage)
> { var tmpWindow = window.open('','_blank',''); //<-- put your
> desired window attributes here
> tmpWindow.document.write('<body leftmargin=0 topmargin=0
> rightmargin=0 bottommargin=0><img src="' +oImage+ '">');
> return false; //or true.. I dunnow ^^}
> </script>
> ===============
>
>
> Tell me if it worked, owk?
>
> ---
> Flavio Gomes
> flavio at economisa.com.br
Thanks again for your helpful ideas.
I ended up with a different solution than I started with. The form
used to have a 'view picture' button which fired a javascript function
to open a new window with the 'file://' url of the local file to
display. IE was throwing 'access denied' errors on the open window
call.
The form now has a img thumbnail for each input="file" element the a
src of "file://". IE will let me change the src of the img to a local
file without throwing an error presumably because the protocols match.
I wonder how long it will be before this loophole is closed :) BTW, it
works in IE6/win, Moz, and Safari.
-------- html --------------
<input type="file" name="pic1" size="35"
onchange="showLocalPic(1, this.value)" />
<img src="file://" height="96" id="preview1" class="invisible" />
------- javascript ---------
function showLocalPic(i, path2Pic) {
if (path2Pic > '') {
/* --- code that was failing ---------
winStats='toolbar=no,location=no,directories=no,';
winStats+='scrollbars=yes,resizable=yes,width=610,height=360';
floater=window.open('file://' + path2Pic, 'Preview', winStats);
floater.focus();
*/
var pic = document.getElementById("preview" + i);
if (pic) {
pic.src = 'file://' + path2Pic;
pic.className = "";
}
} else {
alert('Please select a picture first');
}
}
------------------------------------
I hope this is helpful to someone else...
Roger
-------------------------------------------------------
Roger Roelofs web www.datacompusa.com
Datacomp Appraisal Services web www.mhvillage.com
3215 Eaglecrest Drive, NE Email rer at datacompusa.com
Grand Rapids, MI 49525-4593
More information about the Javascript
mailing list