Object Tag vs. Javascript to embed Ad/Content

Posted on 2009-02-11
Medium Priority
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

Question by:markschenkel
  • 2

Expert Comment

ID: 23631343
<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?



Author Comment

ID: 23632822
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?

Accepted Solution

MikeRCWatts earned 500 total points
ID: 23633036
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...

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question