We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Object Tag vs. Javascript to embed Ad/Content

markschenkel
markschenkel asked
on
Medium Priority
1,132 Views
Last Modified: 2012-05-06
I want to enable people to embed content from my site on theirs by simply copying and pasting a snippet of code.  For comparisons sake, this would be very similar to Google Adsense.  Like Google Adsense, the content will not be static but dynamic and contain images.  

I have been able to accomplish my goal with the snippet of code below.  My question is, what advantages does using JavaScript have over the methodology I am employing?




<object width="200" height="400" data="http://www.mysite.com/showad?mysite_ad_client=933392031200&mysite_ad_slot=30329077" type="text/html" >

Open in new window

Comment
Watch Question

<object> is popular and very widely used for embedding active content like videos, less so for text.

A disadvantage is that IE appears to display a vertical scrollbar even when not needed (remove with css style in the included document-  html { overflow: auto; } and you can remove the border with html { border: none;}

Using a Javascript formulation can give you more control, if you need to sense anything about the containing document's properties or environment.

An advantage of the <object> tag over Javascript is that it can work in a browser which has Javascript disabled, though that is rare.

See this link for some tests and examples (if you haven't already)  http://joliclic.free.fr/html/object-tag/en/object-text.html#html

It may also be looking at the effect on the page loading , as different techniques like Javascript execute at different stages in page loading, and whether there is any effect on caching.  Security looks unaffected by choice of methods to me for including text?

Mike

Author

Commented:
Thanks for the reply.  Actually I will be embedding a combination of html and a image.  The image is a graph which changes from day to day.

I did some more research on this.  The biggest drawback using the <object> tag is Microsoft Explorer comes by default with "Access Datasources Across Domains" unchecked.  Because the content in the object tag is coming from a different domain, it will simply display an empty box.

I did more research Google AdSense.   Someone says that it utilizes IFRAMES.  Is this correct?  So if I rewrite my <Object> to be a <IFRAME>  it should display on any page where Google Adwords can be displayed?
I just tried it cross domain and found my IE security settings prevented the load of the object contents just as you say - sorry, should have checked more carefully not just with local +remote.

Either way, it makes lots of sense to use Google's scheme as it will be well tried and tested...copy with pride...

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.