Здравствуйте, уважаемые. Просьба о помощи, может кто сталкивался с проблемой фреймов в Модх.
Конкретно задача в том, чтобы при открытии сайта, и переходе по ссылкам меню - главная страница оставалась на месте, а остальные бы грузились во фрейме.
Нашла сниппет AutoSizeiFrame_0.1, не пойму, как с ним работать, и то ли это, что мне нужно?
Для наглядности прикрепляю сам код сниппета.
Буду благодарна за любую помощь.
<?php
/**
* AutoSizeiFrame
* Snippet to automatically resize an iFrame to display the full height of its content.
* Original code borrowed from the IFrame SSI script II by Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Ported to MODx by Guillaume Pointel
* Version: 0.1 (January 2007)
* License: GPL
*
* History:
* - 0.1 - First initial public release
*
* Installation:
* Copy the contents of the file into a new snippet named AutoSizeiFrame
*
* Configuration:
* You could use it to display the full heigth of a document embed in your page using the "view port" widget, and just calling the TV in your content area. In this case, recommended settings are :
* - "Stretch To Fit" and "Autosize" set to "yes", rest as default.
* - "Input type" : URL
* - check the correct template access
* Then call this TV and the snippet in the page where you want your iframe put, fill in the URL in the Document Editor
* Warning : the script cannot probe and detect the height of pages from external domains.
* You can also put in your own frame : <iframe id="myframe" src="externalpage.htm" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%; display:none"></iframe>
* Finally, you can also load another document in your iframe using a link in your main document using the javascript "loadintoIframe" function :: <a href="javascript:loadintoIframe('myframe', 'external.htm')">Link</a>
*
* Parameters:
* - $iframeids - Input the name/IDs of the IFRAMES you wish to dynamically resize to match its content height. Separate each ID with a comma. Examples: myframe1,myframe2 or myframe. Be sure to put the exact same ID/name as the view port widget.
* - $iframehide - (optional) yes/no : Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers recommended - default is no, will display the iframe but not resize it - be sure not to put the "Scrollbars" on "no")
*
* exemple : [[AutoSizeiFrame? &iframeids=ID_ViewportWidget_1,ID_iframe_2]]
*/
if(isset($iframeids))
{
$tempid = split(',', $iframeids);
$iframeids = '\'';
foreach($tempid as $v)
$iframeids .= $v . '\', \'';
$iframeids=substr($iframeids,0,-3);
}
else $iframeids = '';
if(!isset($iframehide))
$iframehide='no';
$AutosizeiFrame_js = "<script type='text/javascript'>
/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/
// slightly Modified for use in MODx
//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ['myframe1', 'myframe2'] or ['myframe'] or [] for none:
var iframeids=[" . $iframeids . "]
//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide='" . $iframehide . "'
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf('Firefox')).split('/')[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 32 : 16 //extra height in px to add to iframe in FireFox 1.0+ browsers / 16 : 0
function resizeCaller()
{
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++)
{
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=='no')
{
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display='block'
}
}
}
function resizeIframe(frameid)
{
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera)
{
currentfr.style.display='block'
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener('load', readjustIframe, false)
else if (currentfr.attachEvent)
{
currentfr.detachEvent('onload', readjustIframe) // Bug fix line
currentfr.attachEvent('onload', readjustIframe)
}
}
}
function readjustIframe(loadevt)
{
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}
function loadintoIframe(iframeid, url)
{
if (document.getElementById)
document.getElementById(iframeid).src=url
}
if (window.addEventListener)
window.addEventListener('load', resizeCaller, false)
else if (window.attachEvent)
window.attachEvent('onload', resizeCaller)
else
window.onload=resizeCaller
</script>";
$modx->regClientStartupScript($AutosizeiFrame_js);
?>