document.write

Why do I need to use document.write instead of DOM manipulation methods?

百般思念 提交于 2019-12-10 20:51:27
问题 I'm trying a new ad service, and as far as I know they don't provide a functional interface to loading their ads. We want to display different ad sizes depending on the user's screen size, and this service requires you to load a different .js URL for each size. I originally tried writing: <script type="text/javascript"><!-- var dochead = document.getElementsByTagName('head')[0]; var newscript = document.createElement('script'); newscript.type = "text/javascript"; newscript.src = '//ads-by

HTML “onclick” event in JavaScript (In a table)

老子叫甜甜 提交于 2019-12-10 11:18:21
问题 I'm trying to convert a table I've written in HTML into Javascript because I want the table to be dynamically generated (# of rows). The main issue I'm having is that the individual cells in the table are clickable and open up another html page. Unfortunately, the html "onclick" parameter doesn't work with document.write statements Here is an examples of a table cell in HTML: <td id="r1c1" align="center" onclick="getTicket(1,'plan',1);"><script language="JavaScript">document.write(getDate(1,

jquery dynamic iframe - !document.write and IE issues

江枫思渺然 提交于 2019-12-08 01:59:18
问题 Why does this work in all browsers - except IE: var $iframe = $("<iframe name=" + strFrameName +"/>"); var $doc = $iframe.contents(); $doc.find("head").append("<link type='text/css' rel='stylesheet' href='" + opt.loadCSS + "'>"); However, if I use a non jquery object with document.write, it works ok in IE? var $iframe = $("<iframe name=" + strFrameName +"/>"); var doc = $iframe[0].contentWindow.document; doc.write("<link type='text/css' rel='stylesheet' href='" + opt.loadCSS + "'>"); I

is document.write blocking

一个人想着一个人 提交于 2019-12-07 21:26:28
问题 I would like to insert a script into the page in a blocking way (can't use the src attribute of a script tag unfortunately). Would it block if i inserted the tag via document.write() on all browsers? I know this is a bad way of doing things, but i really need it to block the loading of other resources. Currently i'm doing: document.getElementsByTagName('head')[0].appendChild(dynamic_script_tag_created_previously); But this is not good since it's an asynchroneous load. Thanks for reading and

Overwriting iframe's document.write

南笙酒味 提交于 2019-12-07 16:11:58
问题 For my own purposes ( cough lazy-loading an ad script), I am overwriting the document.write function in order to buffer the script's output, writing it to a div, and restoring the native document.write when I am done. The pseudo-code looks something like this: save off native code document.write redefine document.write eval and buffer output of script when script is done, write buffer to restore native document.write The problem happens in the bolded step - one of the lines in the ad script

How to override JavaScript function from a Firefox extension?

感情迁移 提交于 2019-12-07 10:05:48
问题 I am trying to intercept calls to document.write for all pages. Setting up the interception inside the page by injecting a script like function overrideDocWrite() { alert("Override called"); document.write = function(w) { return function(s) { alert("special dom"); w.call(this, wrapString(s)); }; }(document.write); alert("Override finished"); } Is easy and works, but I would like my extension to setup the interception for each document object from inside the extension. I couldn't find a way to

Recommended method to locate the current script?

荒凉一梦 提交于 2019-12-06 21:22:19
问题 I am writing a script that needs to add DOM elements to the page, at the place where the script is located (widget-like approach). What is the best way to do this? Here are the techniques I am considering: Include an element with an id="Locator" right above the script. Issues: I don't like the extra markup If I reuse the widget in the page, several elements will have the same "Locator" id. I was thinking about adding a line in the script to remove the id once used, but still... Add an id to

HTML “onclick” event in JavaScript (In a table)

▼魔方 西西 提交于 2019-12-06 13:43:18
I'm trying to convert a table I've written in HTML into Javascript because I want the table to be dynamically generated (# of rows). The main issue I'm having is that the individual cells in the table are clickable and open up another html page. Unfortunately, the html "onclick" parameter doesn't work with document.write statements Here is an examples of a table cell in HTML: <td id="r1c1" align="center" onclick="getTicket(1,'plan',1);"><script language="JavaScript">document.write(getDate(1,"plan", "r1c1")); </script></td> The functions in this line are predefined and work so I'm not going to

jquery dynamic iframe - !document.write and IE issues

六月ゝ 毕业季﹏ 提交于 2019-12-06 09:45:21
Why does this work in all browsers - except IE: var $iframe = $("<iframe name=" + strFrameName +"/>"); var $doc = $iframe.contents(); $doc.find("head").append("<link type='text/css' rel='stylesheet' href='" + opt.loadCSS + "'>"); However, if I use a non jquery object with document.write, it works ok in IE? var $iframe = $("<iframe name=" + strFrameName +"/>"); var doc = $iframe[0].contentWindow.document; doc.write("<link type='text/css' rel='stylesheet' href='" + opt.loadCSS + "'>"); I reworked a plugin, and wanted to rewrite it so that it wouldn't use document.write However, now the iframe is

is document.write blocking

谁说胖子不能爱 提交于 2019-12-06 06:30:44
I would like to insert a script into the page in a blocking way (can't use the src attribute of a script tag unfortunately). Would it block if i inserted the tag via document.write() on all browsers? I know this is a bad way of doing things, but i really need it to block the loading of other resources. Currently i'm doing: document.getElementsByTagName('head')[0].appendChild(dynamic_script_tag_created_previously); But this is not good since it's an asynchroneous load. Thanks for reading and thinking about it :) Yes, for example: <script> document.write('<!doctype html><html id="sanitized">