www.webdeveloper.com
Results 1 to 5 of 5

Thread: <object> tag help

  1. #1
    Join Date
    Nov 2008
    Posts
    3

    <object> tag help

    This maybe a css question, I am not sure so I posted it here.

    My basic question is: can you format a <object> tag just like a <div> tag? Is it a block level element?

    I am guessing no, since <img> is an inline element.

    The more complex question:
    In my webpage I want to use the <object> tag to dynamically change the HTML within a rectangular box. So clicking on the menu loads a different html file into the object.

    looks something like this:
    <div id="divid1">
    <object data="default.html" type="text/html">
    <p>Error Loading Content...</p>
    </object>
    </div>
    Then i use javascript to replace the text inside of divid1 to another object:

    function OnClickContactUs() {
    document.getElementById('divid1').innerHTML = "<object data="other.html" type="text/html"><p>Error Loading Content...</p></object>";
    }
    Should that work or am i doing something wrong?

  2. #2
    Join Date
    Sep 2008
    Posts
    12
    We are basically doing this with one of our applications. All you need is to work with iframes.

    Example:

    Code:
    <a class="style677" href="dyna_design.jsp" target="target_frame" onclick="window.open(this.href, this.target)">View this code</a><br>
    
    
    <iframe src="design_pre.jsp" name="target_frame" frameborder="0" width="100%" height="410" style="background-color:F1F1F1" scrolling="no">If you can see this, your browser does not support iframes!
    </iframe>
    What ever link is clicked then loads the href into the frame. You will need to create a page with the codes in them that you like that can be loaded into the iframe. Ihave never had problems working with iframes.

    You can then use the above link in an ordered list:

    Code:
    <ul>
    <li>
    <a class="style677" href="dyna_design.jsp" target="target_frame" onclick="window.open(this.href, this.target)">View code 1</a><br>
    </li>
    <li>
    <a class="style677" href="dyna_design2.jsp" target="target_frame" onclick="window.open(this.href, this.target)">View code 2</a><br>
    </li>
    </ul>
    You can search out some code to make the list into a drop down menu.

    I hope this helps!

  3. #3
    Join Date
    Nov 2008
    Posts
    3
    I keep reading iframes is deprecated. And under strict.dtd, it is not supported? Theres also another post in this forum saying to use strict.dtd for new websites.

    anyhow, I fixed my problem.

    Code:
    function OnClickContactUs() {
    document.getElementById('divid1').innerHTML = '<object data="other.html" type="text/html"><p>Error Loading Content...</p></object>';
    }
    Notice that I had to use single quotes instead of double quotes on the code above.

    Now my problem is with the formatting. <object> tag doesn't seem to inherit the formatting from the parent div. I also assigned an id to object with the right formatting and it doesn;t work 100%. I still can't get the incoming html to be center aligned in the page.

    So I have three new questions:
    1. Should the other.html have any css formatting at all? I formatted to look exactly how I want it, so it looks good if I just load other.html by itself.
    2. Is there a trick to getting an <object> to center align?
    3. other.html is a complete webpage, it has <html>, <head>, <body>, etc. Does that whole html formatting come into my main page? I just don't get how you can have two <body> and <html> tags within one page.

  4. #4
    Join Date
    Nov 2008
    Posts
    3
    I just came upon this article:

    http://htmlhelp.com/faq/html/design.html#include-file

    It says that I should use preprocessor, or server side includes to do what I want. Is that an outdated response, or is <object> still not fully supported for my needs?


    Just from my limited understanding, I am leaning towards preprocessor. Does eclipse have a plugin for an html preprocessor? If not, then my next choice would be SSI or a php script? Someone please advice me on what the easiest choice would be. Thanks
    Last edited by sdweb; 11-05-2008 at 08:08 AM.

  5. #5
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    IE6 and IE7 still have a few issues with using <object> tags.

    See http://www.felgall.com/noiframe.htm for a couple of different ways of using object tags in place of iframe and the issues that those browsers have.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles