par
Faust » 03 déc. 2005, 22:21
Bonjour à tous,
Je veux créer un scripte permettant d'ouvrir une fenêtre popup et de créer un nouveau document HTML.
Mon problème est que je n'arrive pas à utiliser un
document.write() à l'intérieur de cette page. Je m'explique : quand j'affiche la page source du popup, on voit qu'il y a écrit la ligne
document.write() et donc le texte à l'intérieur n'est pas écrit.
function PopupImage(img,url)
{
var gal = "gallery/_" + img + ".jpg";
var war = "gallery/" + img + ".jpg";
if (url=='gal')
{url = gal};
else if (url=='war')
{url = war};
code = '<!DOCTYPE HTML PUBLIC "-\//W3C\//DTD HTML 4.01 Transitional\//EN">\n\n'
code += '<html>\n\n'
code += '<head>\n\n'
code += '<title>Image ' + img + '</title>\n\n'
code += '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\n\n'
code += '<link href="style.css" rel="stylesheet" type="text/css">\n'
code += '<script src="javascript.js" type="text/javascript">\n\n'
code += 'var largeur = document.img.width;\n'
code += 'var hauteur = document.img.height;\n\n'
code += '</script>\n\n'
code += '</head>\n\n'
code += '<body onclick="window.close()">\n\n'
code += '<script type="text/javascript">\n\n'
code += 'document.write(\'<img src="' + url + '" width="\' + largeur + \'" height="\' + hauteur + \'" alt="Close window" name="img" />\');\n\n'
code += '</script>\n\n'
code += '</body>\n\n'
code += '</html>';
popup = window.open('', 'screen', 'width=+w+, height=+h+, top=+y+, left=+x+, toolbar=0, location=0, directories=0, menuBar=0, scrollbars=0, resizable=0');
popup.document.open();
popup.document.write(code);
popup.document.close();
var w = (popup.document.img.width)+14;
var h = (popup.document.img.height)+32;
var x = (screen.width-w)/2;
var y = (screen.height-h)/2;
}
Bonjour à tous,
Je veux créer un scripte permettant d'ouvrir une fenêtre popup et de créer un nouveau document HTML.
Mon problème est que je n'arrive pas à utiliser un [i]document.write()[/i] à l'intérieur de cette page. Je m'explique : quand j'affiche la page source du popup, on voit qu'il y a écrit la ligne [i]document.write()[/i] et donc le texte à l'intérieur n'est pas écrit.
[php]function PopupImage(img,url)
{
var gal = "gallery/_" + img + ".jpg";
var war = "gallery/" + img + ".jpg";
if (url=='gal')
{url = gal};
else if (url=='war')
{url = war};
code = '<!DOCTYPE HTML PUBLIC "-\//W3C\//DTD HTML 4.01 Transitional\//EN">\n\n'
code += '<html>\n\n'
code += '<head>\n\n'
code += '<title>Image ' + img + '</title>\n\n'
code += '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\n\n'
code += '<link href="style.css" rel="stylesheet" type="text/css">\n'
code += '<script src="javascript.js" type="text/javascript">\n\n'
code += 'var largeur = document.img.width;\n'
code += 'var hauteur = document.img.height;\n\n'
code += '</script>\n\n'
code += '</head>\n\n'
code += '<body onclick="window.close()">\n\n'
code += '<script type="text/javascript">\n\n'
code += 'document.write(\'<img src="' + url + '" width="\' + largeur + \'" height="\' + hauteur + \'" alt="Close window" name="img" />\');\n\n'
code += '</script>\n\n'
code += '</body>\n\n'
code += '</html>';
popup = window.open('', 'screen', 'width=+w+, height=+h+, top=+y+, left=+x+, toolbar=0, location=0, directories=0, menuBar=0, scrollbars=0, resizable=0');
popup.document.open();
popup.document.write(code);
popup.document.close();
var w = (popup.document.img.width)+14;
var h = (popup.document.img.height)+32;
var x = (screen.width-w)/2;
var y = (screen.height-h)/2;
}[/php]