SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Dec 2009
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation HTML as Object no Javascript?

    Ok. I am writing Object tags to change the innerHTML of the main div on my site. These Objects are written by clicking on UL Li elements in other divs and grab html pages from the server. The html pages show up fine but if they have any javascript written in them or by external.js the main page throws a header error blocking the scripts from running and any form validation in javascript goes out the window and won't run at all. I was hoping that cdata enclosure tags would help but I guess the objects aren't initialized on the server and require a classId of some kind issued by the server which basicaly shuts that method of calling forms down unless there is another way of referancing the object id to run the script?

    Part of Index Html
    HTML Code:
    <!--============================#MENUE DIV===========================--> 
    
    <div id="menue">
    
    <!--===========================#MENULIST UL===========================--> 
     
    <ul id="menulist">
    <li id="home" class="show" title="Click and Start All Over Again Easily!">Home</li>
    <li id="products" class="show"  title="Our Products.">Products</li>
    <li id="testimonials" class="show"  title="Our Fans Testimonials">Testimonials</li>
    <li id="aboutus" class="show"  title="Articles about us.">About us</li>
    <li id="faq" class="show"  title="Mexicali Rose Order FAQ">Order FAQ</li>
    <li id="contact" class="show"  title="Contact us!">Contact us</li>
    <li id="mexicali" class="hide"  title="Change or Review Your account info.">My Mexicali</li>
    <li><span class="show" id="noofitems" title="Number of items in Your Order."></span></li>
    <li><span class="show" id="ordersum" title="Click to View more of Your Order."></span></li>
    </ul>
    
    </div>
    External.js
    Code:
    //---------------------------#menulist ul--------------------//
    
    /*
    Change f1 innerHTML with object Technique???
    <object id="foo" name="foo" type="text/html" data="aboutus.html"></object>
    */
    
    var aboutus=document.getElementById('aboutus');
    addEvent(aboutus,'click',function(){
    var f1=document.getElementById('f1');
    f1.innerHTML='<object id=articlehtml class=htmlpage type=text/html data=article.html></object>';
    window.history.forward();
    },false);
    
    var testimonials=document.getElementById('testimonials');
    addEvent(testimonials,'click',function(){
    var f1=document.getElementById('f1');
    f1.innerHTML='<object id=testimonialshtml class=htmlpage type=text/html data=testimonials.html></object>';
    },false);
    
    var faq=document.getElementById('faq');
    addEvent(faq,'click',function(){
    var f1=document.getElementById('f1');
    f1.innerHTML='<object id=faqhtml class=htmlpage type=text/html data=faq.html></object>';
    },false);
    
    /*
    function insertcontact()
    {
      document.write('<object id=contacthtml class=htmlpage type=text/html data=contactus.html>\n');
      document.write('<param name=allowScriptAccess value=sameDomain />\n');
      document.write('</object>\n');
    }
    */
    
    //not using this document write as it returns the same result
    
    var contact=document.getElementById('contact');
    addEvent(contact,'click',function(){
    var f1=document.getElementById('f1');
    f1.innerHTML='<object id=contacthtml class=htmlpage type=text/html data=contactus.html></object>'; 
    },false);
    I need to know how to get the object that recognizes the built in javascript?

  2. #2
    SitePoint Addict
    Join Date
    Dec 2009
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up HTML as Object no Javascript?

    BobS @forum.uniserver.com Hey guys I finaly got the javascript written in script tags of the contact.html page which I wrote to the innerHTML of the 'display' div as an object. What it took was amazingly simple. I had to have written an httpServerRequest or Ajax call to the server via external.js before the javascript would run. The call did not have to be made but just had to be there. Lucky for me I had links that required both object and ajax php calls, otherwise I would never have known. Any search on the subject generaly leads to the type swfObject or javaApplet etc. Thanks for that as in general these objects have urls that steer the media player to a proprietary company server that allows the scripts to run. Even though validation is a nusance the classic embed tag allows sounds etc. to be played regardless of what media player is loaded on the client. I didn't get to read your link but saved it to My Favorites and will do so soon. It will be interesting to see how long the browser war will continue to represent proprietory media recognition, a not so subtle form of cronyism bogged down in contract negotiations
    BobS link was a search on swfObject


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •