Re: Load a template using an external event

  •  03-20-2007, 1:15 PM

    Re: Load a template using an external event

    I solved it! Yahoo!
     
    I was trying to send you a short version of my solution, but this reply template keeps refreshing itself for some reason and I lose it all.
     
    Thanks
     
    DOug
     
     
    the solution:
    1. I figure out the template file name I need (fil) and post it to a new window (tmpl)
    Response.Write " var tmpl = ""APGetTemplate.asp?Template="".concat(fil);" & vbCrLf
    Response.Write " new_window = window.open(tmpl, """")" & vbCrLf
     
    2. I catch the file name in the header of my new page.
     
     <%
      Response.Expires = -1
      Dim path
      if Request.QueryString("Template") <> "" then
       Template = Request.QueryString("Template")
      End if
      path = "APTemplates/" & Template
     %> 
     3. My new page has an iframe called 'framepreview' and I fill it up with the desired template code
     
    <iframe id="framepreview" src="<%=path%>"></iframe>
    4. The body onload event calls the following:
     var editor=opener.obj_Description // CuteEditor instance
     var htmlcode='';
     var framepreview = document.getElementById("framepreview").contentWindow; 
     
     function do_insert()
     {
      try{
    // makes a javascript variable pointing to the contents of my iframe
       htmlcode = framepreview.document.getElementsByTagName('HTML')[0].innerHTML;
      }
      catch(er)
      {
       htmlcode = framepreview.document.body.innerHTML;
       var div=document.createElement("DIV");
       div.innerHTML=htmlcode;
       htmlcode =  div.innerText;
      }
     
     
    // stuffs the template code into the editor
      editor.PasteHTML(htmlcode);  
    // closes the pop-up window
      top.close()
      
     }
     
    If the code seems familiar, I confess I pillaged it from your 'insert_template.asp' and 'browse_template.asp' pages.
     
    Thanks for your patience, and for a great product!
     
    DOug
     
     
View Complete Thread