как сделать чтобы в popup окне показывалось картинка?
как сделать чтобы в popup окне показывалось картинка наверху окна как шапка страници?
Вот картинка которое должно показываться в верхном часте popup-окна как шапка popup страницы..... ![]() как это сделать? Вот скрипт которое испоьзуеться в моей страничке:
function f() {
var s = document.getElementById("vwvwprint").innerHTML;
var w2 = window.open("toolbar=0, location=0, directories=0, font-family=Arial, font-size=11px, status=0, menubar=0, scrollbars=0, resizable=0, width=350, height=350");
w2.document.open();
w2.document.write(s);
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = "style.css";
var head = w2.document.getElementsByTagName("head")[0];
head.appendChild(link);
w2.document.close()
}
|
Цитата:
w2.document.getElementsByTagName("body")[0].style.background='url("http://f2.foto.rambler.ru/preview/r/500x375/4692f001-918f-efa8-c60f-d37d57ef671d/ыв.jpg") no-repeat left top';
|
Цитата:
|
ksa, когда вставляю ваш код popup окно не открываеться.....
вот js которое испоьзуеться у меня на страничке:
function f() {
var s = document.getElementById("vwvwprint").innerHTML;
var w2 = window.open("toolbar=0, location=0, directories=0, font-family=Arial, font-size=11px, status=0, menubar=0, scrollbars=0, resizable=0, width=350, height=350");
w2.document.open();
w2.document.write(s);
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = "style.css";
var head = w2.document.getElementsByTagName("head")[0];
head.appendChild(link);
w2.document.close()
}
|
sarik,
документ пустой, body или head надо напечатать ...
w2.document.write('<body style=\'background: url("http://f2.foto.rambler.ru/preview/r/500x375/4692f001-918f-efa8-c60f-d37d57ef671d/ыв.jpg") no-repeat left top\'>')
w2.document.write(s);
|
sarik,
Синтаксис window.open |
рони, теги html, head и body необязательны в разметке - они воссоздаются автоматически при необходимости во время чтения "потока" документа (во время записи document.write() )
|
Цитата:
|
<!DOCTYPE html>
<script>
setTimeout(function(){
var serializer = new XMLSerializer();
alert(serializer.serializeToString(document.documentElement));
document.open();
alert(serializer.serializeToString(document.documentElement || document.createElement('undefined')));
document.write('<p>Тест</p>');
alert(serializer.serializeToString(document.documentElement));
}, 100);
</script>
|
danik.js,
спасибо, но пока я слабо разбираюсь что значит ваш код ... применительно к
w2.document.getElementsByTagName("body")[0].style.background='url("http://f2.foto.rambler.ru/preview/r/500x375/4692f001-918f-efa8-c60f-d37d57ef671d/ыв.jpg") no-repeat left top';
ну или по вашему Цитата:
|
<!DOCTYPE html>
<script>
setTimeout(function(){
alert(document.body);
document.open();
alert(document.body);
document.write('<p>Тест</p>');
alert(document.body);
}, 100);
</script>
|
danik.js,
ещё раз спасибо ... но вставить картинку в стиль боди я не смог, думал вы мне поможите. |
<!DOCTYPE html>
<script>
setTimeout(function(){
document.open();
document.write('<p>Тест</p>');
document.close();
document.body.style.background = 'url(http://f2.foto.rambler.ru/preview/r/500x375/4692f001-918f-efa8-c60f-d37d57ef671d/ыв.jpg)';
}, 100);
</script>
|
danik.js,
ок ))) код ниже у меня несрабатывал, сейчас нормально.чего нехватало так и непонял.
<!DOCTYPE HTML>
<html>
<head>
<title></title>
</head>
<body>
<div id="vwvwprint">555555777</div>
<script>
function f() {
var s = document.getElementById("vwvwprint").innerHTML;
var w2 = window.open("","","width=350, height=350");
w2.document.open();
w2.document.write(s);
w2.document.close()
w2.document.body.style.background='url("http://f2.foto.rambler.ru/preview/r/500x375/4692f001-918f-efa8-c60f-d37d57ef671d/ыв.jpg") no-repeat left top'
}
f();
</script>
</body>
</html>
|
не работаеть...окно не открываеться когда вставляю
w2.document.getElementsByTagName("body")[0].style.background='url("http://f2.foto.rambler.ru/preview/r/500x375/4692f001-918f-efa8-c60f-d37d57ef671d/ыв.jpg") no-repeat left top';
|
Цитата:
Цитата:
|
Цитата:
Цитата:
|
Полный код дай.
|
function f() {
var s = document.getElementById("vwvwprint").innerHTML;
var w2 = window.open("width=350, height=350");
w2.document.open();
w2.document.write(s);
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = "style.css";
var head = w2.document.getElementsByTagName("head")[0];
head.appendChild(link);
w2.document.close()
}
<img src="print.p.jpg" onclick="f()"> |
Что-то я в упор не вижу w2.document.body.style.background
|
function f() {
var s = document.getElementById("vwvwprint").innerHTML;
var w2 = window.open("width=350, height=350");
w2.document.open();
w2.document.write(s);
w2.document.body.style.background='url("http://f2.foto.rambler.ru/preview/r/500x375/4692f001-918f-efa8-c60f-d37d57ef671d/ыв.jpg") no-repeat left top'
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = "style.css";
var head = w2.document.getElementsByTagName("head")[0];
head.appendChild(link);
w2.document.close()
}
<img src="print.p.jpg" onclick="f()"> |
В хроме работает. А где не работает?
<script>
function f() {
var s = document.getElementById("vwvwprint").innerHTML;
var w2 = window.open("width=350, height=350");
w2.document.open();
w2.document.write(s);
w2.document.body.style.background='url("http://f2.foto.rambler.ru/preview/r/500x375/4692f001-918f-efa8-c60f-d37d57ef671d/ыв.jpg") no-repeat left top'
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = "style.css";
var head = w2.document.getElementsByTagName("head")[0];
head.appendChild(link);
w2.document.close()
}
</script>
<img src="print.p.jpg" onclick="f()">
<div id="vwvwprint">xxx</div>
|
sarik,
может див забыли? <div id="vwvwprint">555555777</div> |
странная ссылка "width=350, height=350" )))
вроде на синтаксис ссылку давал.... |
Цитата:
|
У меня работает в опере.
Цитата:
|
Я понял из за чего у меня не работаеть.
у меня все скрипти в php файле стоять и поэтому мне придеться заменить в любом скрипет ' на " ....и когда я заменяю 'на " то js перестанеть работать. А можно как то без ' ? и там где
'url("cc-logo-tj.jpg") no-repeat left top'
я делаю так
"url("cc-logo-tj.jpg") no-repeat left top"
|
sarik,
а слешем экранировать \" ? |
<?php echo 'bla bla' ?>
<script>
var string = "no prob'lem";
</script>
|
Цитата:
Цитата:
|
Цитата:
|
Цитата:
|
| Часовой пояс GMT +3, время: 08:25. |