Object Tag vs. Javascript to embed Ad/Content

Posted on 2009-02-11
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="" type="text/html" >

Open in new window

Question by:markschenkel
    LVL 5

    Expert Comment

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

    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

    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?
    LVL 5

    Accepted Solution

    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

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
    Article by: DanRollins
    This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (, we'll extend the program by adding a depth-…
    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…

    732 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now