Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Connie DeCinko 931 posts 1159 karma points
    Jun 06, 2011 @ 20:00
    Connie DeCinko
    0

    Cross Domain iFrame Height in XSLT

    I'm trying to use the cross domain iframe height example here:  http://css-tricks.com/cross-domain-iframe-resizing/

    I can't get my XSLT to save without error.  Right now, I get "An error occurred while parsing EntityName. Line 45, position 61."

    My XSLT is below:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
      exclude-result-prefixes="msxml  umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes  Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings  Exslt.ExsltSets ">

    <xsl:output method="html" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <xsl:param name="iframeSource" select="/macro/source" />
    <xsl:param name="iframeName" select="/macro/name" />
    <xsl:param name="qryString" select="umbraco.library:RequestServerVariables('QUERY_STRING')" />

    <xsl:template match="/">
      <script type="text/javascript">
        function resizeFrame(f) {
          var size;
        // size = f.contentWindow.document.body.scrollHeight + 10;
        //  f.style.height = size + "px";
        }

      
        $(function(){

          // Keep track of the iframe height.
          var if_height,

          // Pass the parent page URL into the Iframe in a meaningful way (this URL could be
          // passed via query string or hard coded into the child page, it depends on your needs).
          src = 'http://{umbraco.library:Replace(umbraco.library:RequestServerVariables("SERVER_NAME"),".azbar.",".myazbar.")}/{$iframeSource}?{$qryString}#' + encodeURIComponent(document.location.href),
        
          // Append the Iframe into the DOM.
          iframe = $('<iframe src="' + src + '" width="100%" height="600" frameborder="0" scrolling="no" allowtransparency="yes" marginheight="0" marginwidth="0"></iframe>')
            .appendTo('#iframe');
      
          // Setup a callback to handle the dispatched MessageEvent event. In cases where
          // window.postMessage is supported, the passed event will have .data, .origin and
          // .source properties. Otherwise, this will only have the .data property.
          $.receiveMessage(function(e){
        
            // Get the height from the passsed data.
            var h = Number(e.data.replace(/.*if_height=(\d+)(?:&|$)/,'$1'));
        
            if ( !isNaN( h ) && h > 0 && h !== if_height ) {
              // Height has changed, update the iframe.
              iframe.height( if_height = h );
            }
        
          // An optional origin URL (Ignored where window.postMessage is unsupported).
          }, 'http://www.azbar.dev' );
     
          });
      
        });
      </script>
     
    </xsl:template>

    </xsl:stylesheet>
  • Connie DeCinko 931 posts 1159 karma points
    Jun 06, 2011 @ 20:39
    Connie DeCinko
    0

    Ok, one step closer.  I figure out the error above.  Now, I need to figure out how to get the XSLT to pass my server variables inside the script.

      <script type="text/javascript">
        $(function(){

          // Keep track of the iframe height.
          var if_height,

          // Pass the parent page URL into the Iframe in a meaningful way (this URL could be
          // passed via query string or hard coded into the child page, it depends on your needs).
          src = 'http://www.myazbar.dev/Preferences/personalpreferences1.cfm#' + encodeURIComponent( document.location.href ),
          // Append the Iframe into the DOM.
          iframe = $('<iframe src="' + src + '" width="100%" frameborder="0" scrolling="no" allowtransparency="yes" marginheight="0" marginwidth="0"></iframe>')
            .appendTo('#iframe');
     
          // Setup a callback to handle the dispatched MessageEvent event. In cases where
          // window.postMessage is supported, the passed event will have .data, .origin and
          // .source properties. Otherwise, this will only have the .data property.
          $.receiveMessage(function(e){
        
            // Get the height from the passsed data.
            var h = Number(e.data.replace(/.*if_height=(\d+)(?:&amp;|$)/,'$1'));
        
            if ( !isNaN( h ) &amp;&amp; h > 0 &amp;&amp; h !== if_height ) {
              // Height has changed, update the iframe.
              iframe.height( if_height = h );
            }
        
          // An optional origin URL (Ignored where window.postMessage is unsupported).
          }, 'http://{umbraco.library:Replace(umbraco.library:RequestServerVariables("SERVER_NAME"),".azbar.",".myazbar.")}' );
      
        });
      </script>

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies