...

View Full Version : popup access denied document.write



leocoding
06-04-2005, 04:26 PM
l.s.

when i try to popup a window (see script bellow) in get a message saying that access is denied, i tried everything (perhaps i missed one) but it comes back every time. perhaps there is someone who can help me??

script:
<html>

<head>

<script type="text/javascript">
// Niks veranderen aan de HEAD-tag
<!-- Begin
function PrevFoto(img){
foto1= new Image();
foto1.src=(img);
Controle(img);
}
function Controle(img){
if((foto1.width!=0)&&(foto1.height!=0)){
viewFoto(img);
}
else{
functie="Controle('"+img+"')";
interval=setTimeout(functie,20);
}
}
function viewFoto(img){
breed=foto1.width + 20;
hoog=foto1.height + 20;
string="width=" + breed + ",height=" + hoog;
venster=window.open(img,"",string);
venster.document.write('<html><body topmargin=0 leftmargin=0>');
document.write('<img src=" ' & img & '" alt="leo met slang">');
document.write('</body></html>');
document.open()
//Deze code gebruiken om geen randen rond de afbeelding te krijgen anders weglaten
}
// End -->
</script>

</head>



<body>

<A HREF="javascript:PrevFoto('C:/Documents and Settings/Leo/My Documents/Mijn webs/mijnweb214/images/huisdieren/IMG_1950.JPG')" > <IMG SRC='C:/Documents and Settings/Leo/Desktop/web tools/images/smile.gif' BORDER='0'></A>


</body>

</html>

devosc
06-04-2005, 04:38 PM
Not sure really, presumably cross site scripting is not occuring, here... look at you doc write line you have & instead of + ???

leocoding
06-04-2005, 06:15 PM
i tried that already , but the error access denied starts at the first at the first venster.document.write. i also tried to get my security down to the lowest level, but what ever i tried ...... no success. the window popup does show as soon as i remove "venster".

martin_narg
06-04-2005, 06:39 PM
Try this:



<script type="text/javascript">
// Niks veranderen aan de HEAD-tag
<!-- Begin
function PrevFoto(img){
foto1= new Image();
foto1.src=(img);
Controle(img);
}
function Controle(img){
if((foto1.width!=0)&&(foto1.height!=0)){
viewFoto(img);
}
else{
functie="Controle('"+img+"')";
interval=setTimeout(functie,20);
}
}
function viewFoto(img){
var venster=window.open("","","width=" + (foto1.width + 20) + ",height=" + (foto1.height + 20));
venster.document.open();
venster.document.write('<html><body topmargin=0 leftmargin=0>');
venster.document.write('<img src="' + img + '" alt="leo met slang">');
venster.document.write('</body></html>');
venster.document.close();
//Deze code gebruiken om geen randen rond de afbeelding te krijgen anders weglaten
}
// End -->
</script>


hope this helps

m_n

leocoding
06-05-2005, 10:13 AM
thanks for the effort, but this script also gives the same error 'access denied'
on the first statement: venster.document.open

martin_narg
06-05-2005, 12:20 PM
I used this script with no errors in IE or Firefox:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function viewFoto(img){
var foto1 = document.getElementById("foto1").style;

var venster = window.open("","","height="+(foto1.width + 20)+",width="+(foto1.height + 20));
venster.document.open();
venster.document.write('<html><body topmargin=0 leftmargin=0>');
venster.document.write('<img src=" ' + img + '" alt="leo met slang">');
venster.document.write('</body></html>');
venster.document.close();
//Deze code gebruiken om geen randen rond de afbeelding te krijgen anders weglaten
}
</script>
<title>Untitled Document</title>
</head>

<body><a href="#" onclick="viewFoto('myGif.gif');">launch window</a>
<div id="foto1" style="width: 200px; height: 200px;">&nbsp;</div>
</body>
</html>


Please note the declaring of the variables and using + instead of & as a string concatenator.

Hope this helps.

m_n

leocoding
06-05-2005, 12:38 PM
martin,

it is driving me mad, this source also gives me an "access denied" error. might it be something to do with a security item?


Leo

enumerator
06-05-2005, 12:41 PM
thanks for the effort, but this script also gives the same error 'access denied'
on the first statement: venster.document.open

This is a local file, so your internet security settings are probably disallowing access to it...

enumerator
06-05-2005, 12:53 PM
it is driving me mad, this source also gives me an "access denied" error. might it be something to do with a security item?
info linked here: http://codingforums.com/showpost.php?p=269050&postcount=2

leocoding
06-05-2005, 07:18 PM
sorry,

but even this is not giving a solution, i hope to hear more,

leo

rwedge
06-05-2005, 07:40 PM
These URL's

'C:/Documents and Settings/Leo/My Documents/Mijn webs/mijnweb214/images/huisdieren/IMG_1950.JPG'
'C:/Documents and Settings/Leo/Desktop/web tools/images/smile.gif'

shouldn't they be
'C:\Documents and Settings\Leo\My Documents\Mijn webs\mijnweb214\images\huisdieren\IMG_1950.JPG'
'C:\Documents and Settings\Leo\Desktop\web tools\images\smile.gif'

/Bob

leocoding
06-06-2005, 10:55 AM
changing the slash to backslash does not do the trick

leocoding
06-06-2005, 04:52 PM
ok, we go on,
in htmlkit this works:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitledhead></title>

<script language="JavaScript">
<!--
//
function Foto(img){
foto1= new Image();
foto1.src=(img);
CheckFoto(img);
}
function CheckFoto(img){
if((foto1.width!=0)&&(foto1.height!=0)){
viewFoto(img);
}
else{
uitvoering="CheckFoto('"+img+"')";
interval=setTimeout(uitvoering,20);
}
}
function viewFoto(img){
imgbreedte=foto1.width;
imghoogte=foto1.height;
vars="width="+imgbreedte+",height="+imghoogte+",left="+((screen.width-imgbreedte)/2)+",top="+((screen.height-imghoogte)/2);
newwindow=window.open("","proximedia",vars);
newwindow.document.write("<html>\n<head>\n<title>"+img+"</title>\n");
newwindow.document.write("<meta http-equiv=\"imagetoolbar\" content=\"no\">\n");
newwindow.document.write("</head>\n\n<body style=\"margin: 0 0 0 0;\">\n");
newwindow.document.write("<img src=\""+img+"\" border=\"0\" onclick=\"javascript:window.close()\">\n");
newwindow.document.write("</body>\n</html>\n");
newwindow.document.focus();
newwindow.document.close();
}
// einde script -->
</script>


</head>
<body>
<a href="javascript:Foto('C:/Documents and Settings/Leo/Desktop/test html/864-skull2.gif')"><img src="C:/Documents and Settings/Leo/Desktop/test html/smile.gif" border="0" ></a>

</body>
</html>


but in frontpage the same problem: access denied!!!! anybody an idee why???

rwedge
06-06-2005, 10:42 PM
Look at the URLs in your browser address bar. NO windows OS uses forward slashes in it's directory structure.

The script works and is not something to be fixed. What doesn't work is wrong paths and evidently Frontpage, which is not a javascript problem nor a good method of publishing web pages.

/Bob



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum