Ticket #5366 (closed bug: duplicate)
Unwanted page reload when using load funciton in Firefox to serve random affiliate ads
| Reported by: | bounsy | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4 |
| Component: | ajax | Version: | 1.3.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
A detailed set of test cases I came up with can be found here (with more discussion above this comment): http://drupal.org/node/355251#comment-2148332
Essentially, I am trying to serve up random ads on my site using the jQuery load function (which is being used by the advertisement module in Drupal). Some of the ads are from affiliates that include JavaScript files that include document.write function calls in them. In Firefox, this causes the page to reload and show only the ad against a blank background. Internet Explorer works correctly.
Change History
comment:2 Changed 4 years ago by dmethvin
- Status changed from new to closed
- Resolution set to duplicate
I agree with pbcomm on the right way to deliver ads; they really should be in an iframe so they're isolated from the page. There are several tickets already open regarding the processing of scripts via ajax including #4826 so I'll close this as a duplicate.
comment:3 Changed 4 years ago by bounsy
It may be a duplicate of the existing case. Is that case being worked on? There are no comments on it.
Here's some test code that has nothing to do with ads that does not work correctly in either Internet Explorer or Firefox.
<html>
<head>
<script type="text/javascript" src="/misc/jquery.js"></script>
</head>
<body>
<h1>test</h1>
<div id="group-id-1">
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){ jQuery("div#group-id-1").html('<div align="center"><script type="text/javascript" language="javascript">document.write("<h1>foo</h1>")</' + 'script></div>'); )});
//]]>
</script>
</div>
</body>
</html>
In Internet Explorer, the text "foo" is never displayed. In Firefox, the entire page is replaced with the text "foo".
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

This is NOT a jQuery issue. Most ad companies deliver their content by using document.write. Try using iFrames to host your ads or inserting the code directly into html page.