|
|
|
|
|
для: elenaki
(17.12.2007 в 13:21)
| | ошибка... Верхний код не нужен, нужно как-то сделать тоже самое для iframe | |
|
|
|
|
|
|
|
для: IrinaI
(17.12.2007 в 13:14)
| | <FRAMESET> и <BODY> - две вещи несовместные, как гений и злодейство... | |
|
|
|
|
|
|
| На странице расположено два iframe, необходимо, чтобы они перемещались синхронно при скроллинге одного из ползунков. Есть скрипт, позволяющий делать это с фреймами, но переделать под iframe не получается.
Для фреймов:
Файл с фреймами:
<HTML>
<HEAD>
<TITLE>Horizontal Synchronization with Frames</TITLE>
</HEAD>
<FRAMESET id="fscroll" name="fscroll" cols="150,*">
<FRAME src="fscroll_left.html" name="left" id="left">
<FRAME src="fscroll_right.html" name="right" id="right">
</FRAMESET>
<BODY>
<P>Ваш браузер не поддерживает фреймы</P>
</HTML>
fscroll_right.html
<html>
<head>
<title>Right Frame</title>
<script type="text/javascript">
var _run; // Set an empty variable named “_run”
if(navigator.userAgent.indexOf("Firebird")!=-1||navigator.userAgent.indexOf("Firefox")!=-1||navigator.appName=="Microsoft Internet Explorer") // if the browser is Firebird/Firefox or MSIE
{_run=false;} // set the variable _run to false
else {_run= true;} // otherwise, set _run to true
function scrollR()
{
var left =
(window.pageXOffset)?(window.pageXOffset):(document.documentElement)?document.documentElement.scrollLeft:document.body.scrollLeft;
/* If window.pageXOffset is defined, set left to the pageXOffset of the current document. If it isn’t and
document.documentElement is defined, set left to document.documentElement.scrollLeft. If document.documentElement and window.pageXOffset are both undefined, set the variable to document.body.scrollLeft */
parent.frames["left"].scrollTo(left);
/* Now scroll the left frame to the amount of pixels this document is from the left. If you scroll 3 pixels from the left (to the right) on this frame, the left document will be scrolled by exactly the same amount. This is how the frames are synchronized. */
}
function searchScroll(){
var left = (window.pageXOffset)?(window.pageXOffset):(document.documentElement)?document.documentElement.scrollLeft:document.body.scrollLeft;
/* This is the same as was what we created earlier. Here, we set the variable (in pixels) indicating where the document has been scrolled from the left to the right. */
/* Again, we’re setting the variable “top” to equal the amount of pixels the document is scrolled from the top of the window, and using it to calculate how far from the top the opposite frame should scroll. .*/
parent.frames["left"].scrollTo(left); /* scroll the left frame to wherever this frame is scrolled to */
window.setTimeout("searchScroll();",1); /* run this function one time every millisecond, or 1,000 times a second */
}
if(_run == false) {
window.onscroll=function(){scrollR();} /* run the function scrollR() when the document is scrolled */
} else { // if the variable _run is set to true
window.onload=function(){searchScroll()} /* when the document loads, run the searchScroll() function 1,000 times a second (because there is a setTimeout() function inside the searchScroll() function). */
}
</script></head>
<body>
<div style="width:900px; height: 900px;">Testing...</div>
</body></html> | |
|
|
|
|