Linking URL in Object tag, make it...

User 597929 Photo


Registered User
1,332 posts

Okay, so if I have a <div> block with a size and location all set up, and inside that box I want to be displayed a web page, the Strict XHTML way to do so is supposed to be the <object> tag, or so my readings have led me to believe. Problem is, it works great in Firefox but just shows a blank space in IE7. Googling shows me IE7 has issues with <object> but doesn't show me any fixes when the thing in the tag is a URL.

Anyone have ideas? Here's a sample snippet I've been using (nested inside a <div>):

<object type="text/html" data="http://www.google.com"
style="height:100%; width:100%;">
<p>Alternate text.</p>
</object>
"You can't be a real country unless you have a beer and an airline - it helps if you have some kind of a football team, or some nuclear weapons, but at the very least you need a beer." -- Frank Zappa

Visit Spinland Studios: http://www.spinland.biz
User 122279 Photo


Senior Advisor
14,649 posts
Online Now

I tried your code in IE8, and it works. Only the height of 100% gets ignored, and instead the google website appears just in a wee slot, 100% wide though. I get the same result in FF (latest), whereas Safari pays attention to the height and shows the whole page.

I don't know why this happens, though.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 597929 Photo


Registered User
1,332 posts

Yeah, so far as I know they've made IE8 at least more <object> compliant (won't go so far as to say fully), but IE7 and earlier is still a major problem. I was hoping someone knew of a work-around.

On the height issue, I believe it's because that snippet needs to be inside a <div> element with dimensions specified, so the % has something to work with. For example:

<div class="object_window" style="left: 22px; top: 105px; width: 930px; height: 650px;">

<object type="text/html" data="http://www.google.com"
style="height:100%; width:100%;">
<p>Alternate text.</p>
</object>

</div>


Your page would have to be large enough to fit the size of the <div>.
"You can't be a real country unless you have a beer and an airline - it helps if you have some kind of a football team, or some nuclear weapons, but at the very least you need a beer." -- Frank Zappa

Visit Spinland Studios: http://www.spinland.biz
User 38401 Photo


Senior Advisor
10,951 posts

Wouldn't this fall under the same issues that our CC programs use to get around this? Most of them have that Fix for Active Content checkbox, I would imagine the same setup would work for this? Just a thought since I haven't tried it :P
User 463058 Photo


Ambassador
1,086 posts

Take a look at these pages and see if they help. However, I think trying to pull in pages from outside servers can also contribute to the problem in the case of browsers which don't allow this for security reasons or whatever.

http://aplus.rs/web-dev/insert-html-pag … html-page/

http://intranation.com/test-cases/object-vs-iframe/
User 597929 Photo


Registered User
1,332 posts

Thanks, Cary, but I actually already looked at both of those pages today, copy and pasted in their code, and their stuff simply does not work. I've tried it in both IE7 and IE8 on two different computers and two different networks and all I see with their code is the same empty box I got before.
"You can't be a real country unless you have a beer and an airline - it helps if you have some kind of a football team, or some nuclear weapons, but at the very least you need a beer." -- Frank Zappa

Visit Spinland Studios: http://www.spinland.biz
User 463058 Photo


Ambassador
1,086 posts

I would just use an iframe if it does the job.
User 597929 Photo


Registered User
1,332 posts

Looks like I'm going to have to. It's frustrating, but what do you do? :rolleyes:

Thanks again.
"You can't be a real country unless you have a beer and an airline - it helps if you have some kind of a football team, or some nuclear weapons, but at the very least you need a beer." -- Frank Zappa

Visit Spinland Studios: http://www.spinland.biz
User 463058 Photo


Ambassador
1,086 posts

I just found one page that actually says, the "solution does not work in IE if you are trying to pull content from a remote server."

http://stackoverflow.com/questions/3114 … -an-iframe
User 597929 Photo


Registered User
1,332 posts

Okay, the light has dawned. Their code only works if you reference a specific file, not a URL. You can't bring in, for example, http://www.google.com, but you can bring in a local file like mystuff/mypage.html.

That should address your security concern about outside servers, though you can still use an outside URL in the actual <object> spec and it works in Firefox for any address.

This was probably an exercise in useless information but for some damned reason it offended me not to have a workable solution.
"You can't be a real country unless you have a beer and an airline - it helps if you have some kind of a football team, or some nuclear weapons, but at the very least you need a beer." -- Frank Zappa

Visit Spinland Studios: http://www.spinland.biz

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.