What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 130 Stack Exchange communities.

Go to any page on stackoverflow.com, open firebug (or use some other html searching feature), and put in "everyonelovesstackoverflow" into the search bar. There's one div in the html with that class (second child of the sidebar), its contents are thus:

<div class="everyonelovesstackoverflow">
        <script type="text/javascript">
            document.write('<s'+'cript lang' + 'uage="jav' + 'ascript" src="http://ads.stackoverflow.com/a.aspx?ZoneID=4&amp;Task=Get&amp;IFR=False&amp;PageID=52405&amp;SiteID=1&amp;Random=' + (+new Date()) + '">'); 
            document.write('</'+'scr'+'ipt>');
        </script><script src="http://ads.stackoverflow.com/a.aspx?ZoneID=4&amp;Task=Get&amp;IFR=False&amp;PageID=52405&amp;SiteID=1&amp;Random=1259617729992" language="javascript"/><a rel="nofollow" target="_Blank" href="http://ads.stackoverflow.com/a.aspx?Task=Click&amp;ZoneID=4&amp;CampaignID=64&amp;AdvertiserID=7&amp;BannerID=21&amp;SiteID=1&amp;RandomNumber=2015326516&amp;Keywords="><img width="220" height="250" border="0" align="Center" alt="Free book on best practices for peer code review at codereviewbook.com - Smart Bear Software" src="http://ads.stackoverflow.com/ads/freebook.png"/></a><br/>
        <noscript>
            <div>
            <a href="http://ads.stackoverflow.com/a.aspx?ZoneID=4&amp;Task=Click&amp;Mode=HTML&amp;SiteID=1&amp;PageID=52405">
            <img src="http://ads.stackoverflow.com/a.aspx?ZoneID=4&amp;Task=Get&amp;Mode=HTML&amp;SiteID=1&amp;PageID=52405" alt="">
            </a>
            </div>
        </noscript>
    </div>

What in the world is this? My first question is why in the world you'd use javascript to write a <script> tag (in little pieces?) into a document. When I put in ads.stackoverflow.com, it takes me to a login for a stackoverflow advertising page, so I'm guessing they're references to a script that shows an ad on the page.

But perhaps foremost I'm asking if this is a bug. Its an odd name for a div on this well designed site, and the div never seems to have any content. ever. The only other reference I've found to this div is this question, in a greasemonkey script that reverses the reduced advertising when you hit 200 rep, so I thought it was an add. I've disabled ad-block plus and greasemonkey, logged out, and visited the site, and the div still has the same source-code, but nothing ever appears in it. Can anyone else see an ad in that div? (as my cookies or other factors could be interfering with what I see). This just smells weird, can anybody give an explanation?

EDIT: OK, now I see the ad. Maybe I'm just being an idiot,

share|improve this question

1 Answer 1

up vote 5 down vote accepted

The "<script> in fragments" thing was weird to me too, but I asked on Twitter and this is still standard. Apparently certain HTML validators freak out if they see "tags" inside your script. I researched it at the time and it's legit, but I can't remember all the details at the moment.

Here's your answer.. from this "Stack Overflow" site, whatever the heck that is.

http://stackoverflow.com/questions/1659749/script-tag-in-javascript-string

share|improve this answer
4  
And since when you care about validators? –  John the Seagull Nov 30 '09 at 23:31
    
not just validators, I couldn't remember all the reasons. See the post. –  Jeff Atwood Dec 1 '09 at 4:13
    
The scripts just won't work. Some browsers look for the word <script and automatically prevent it from inclusion in the dom. –  Joel Coehoorn Dec 1 '09 at 4:18
1  
A more interesting question is why the javascript is pulled form stackoverflow.com rather than sstatic.com –  Joel Coehoorn Dec 1 '09 at 4:19
    
Oh, and you can see this with google, too. It's how the google analytics scripts work. –  Joel Coehoorn Dec 1 '09 at 4:20
1  
...hmm... maybe I shoulda just added my own answer :) –  Joel Coehoorn Dec 1 '09 at 4:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .