We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21023
    • 4 Posts
    Здравствуйте, уважаемые. Просьба о помощи, может кто сталкивался с проблемой фреймов в Модх.
    Конкретно задача в том, чтобы при открытии сайта, и переходе по ссылкам меню - главная страница оставалась на месте, а остальные бы грузились во фрейме.

    Нашла сниппет 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);
    ?>



      • 23695
      • 230 Posts
      вам лучше ajax использовать, очень много готовых простых библиотек которые легко встраиваются, например http://difour.org/blog/more/ajax_simple_loading/
        • 33694
        • 742 Posts
        Всё это конечно круто, но когда человек спрашивает про то, как ему использовать фреймы, рассказ о прелестях простых готовых библиотек Ajax которые легко встраиваются думаю не то, что он хотел бы услышать. wink
          • 22301
          • 1,084 Posts
          Naty, на самом деле проблем с использованием фреймов, связанных с MODx, нет и быть не может.

          Совет только один -- учи матчасть (HTML, не MODx).

          Сниппетов, которые сами "построят" фрейм нет и, опять же, быть не может. Также как нет и не может быть сниппетов, которые бы отвёрстывали автоматом слои или таблицы, например.

          Приведённый код сниппета даже ковырять лень, достаточно названия, чтобы понять, что он тебе не нужен. Во всяком случае, ты точно сейчас не в состоянии понять, зачем он может тебе понадобиться.

          P. S. если не затруднит, укажи в профайле Gender wink
            [img]http://jurist-info.ru/pic/rrr.jpg[/img]

            Безжалостный пияр!
            Artima -- неуч!
            Осторожно: преступная локализация -- modx-cms.ru
            Баштанник Андрей -- мегапрограммер из Белоруссии и поедатель говна, очень критично настроенный молодой человек!

            Дисклеймер для общительных: даю сам себе право транслировать в открытый эфир содержание лички, just for fun
            • 1788
            • 1,103 Posts
            Как вариант:
            Параметры (TV) => Визуальный компонент: ViewPort
              • 21023
              • 4 Posts
              Всем спасибо за помощь. Нашла другой способ.
                • 897
                • 1,620 Posts
                я и другие сообщники с интересом посчитаем про найденное вами решение
                  "Und wenn du lange in einen Abgrund blickst, blickt der Abgrund auch in dich hinein."

                  Не используйте Revo для "просто сайтов". Используйте Evo

                  Who can defeat the Russian bear?
                  • 21023
                  • 4 Posts
                  Просто воспользовалась css, свойством прокрутки div-а:
                  #contentfull {
                  height:600px;
                  width:677px;
                  position:relative;
                  z-index:1000;
                  overflow:auto;
                  margin:0;
                  padding:0;
                  }