/    Sign up×
Community /Pin to ProfileBookmark

<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:

[QUOTE]

<div id=”divid1″>
<object data=”default.html” type=”text/html”>
<p>Error Loading Content…</p>
</object>
</div>

[/QUOTE]

Then i use javascript to replace the text inside of divid1 to another object:

[QUOTE]

function OnClickContactUs() {
document.getElementById(‘divid1’).innerHTML = “<object data=”other.html” type=”text/html”><p>Error Loading Content…</p></object>”;
}

[/QUOTE]

Should that work or am i doing something wrong?

to post a comment
HTML

4 Comments(s)

Copy linkTweet thisAlerts:
@the_heroNov 04.2008 — 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>[/CODE]


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>[/CODE]


You can search out some code to make the list into a drop down menu.

I hope this helps!
Copy linkTweet thisAlerts:
@sdwebauthorNov 05.2008 — 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>';
} [/CODE]


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.
Copy linkTweet thisAlerts:
@sdwebauthorNov 05.2008 — 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
Copy linkTweet thisAlerts:
@felgallNov 05.2008 — 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.
×

Success!

Help @sdweb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.12,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...