Help Me Do The Right DOM Thing.

Nov 2, 2006

I have read all the reason why DOM purists don't like document.write
and innerHTML. I would like to be a good programmer and do the right
thing and not use them. But I need your help to get it to what the
project needs done.

In the interest of brevity, the following code has been simplified.
You'll notice sDoc contains HTML and JavaScript, this is a
unchangeable requirement. PLEASE don't waste your time or mine by
explaining how un-couth it is. I know it is but there's nothing I can
do about. Answers strictly focused what can be done versus what should
be done will be greatly appreciated.

There are three attempted methods to render the sDoc. The first one is
to create a textNode and append it to a div. It prints the code as
text instead of rendering it, as expected. Is it possible to get it to
render?

The second method uses innerHTML and the HTML is rendered but not the
JavasScript.

The third method uses document.write which renders both the HTML and
JavaScript, but we really really don't want to use the write method,
but at this point it looks like we have no choice.

We've even tried to render sDoc in a DOM created iFrame, but it chokes
in Mozilla browsers because of the known bug of included scripts that
use document.write (once again another requirement that can't be
changed) kills the page as document.close fails.


<div id="foo1" style="border:1px solid black;"></div>
<div id="foo2" style="border:1px solid black;"></div>
<script type="text/javascript">
var sDoc = '<center><scr'+'ipt
language=javascript>alert(true);</scr'+'ipt></center>'
var myText = document.createTextNode(sDoc);
document.getElementById("foo1").appendChild(myText);
document.getElementById("foo2").innerHTML = sDoc;
document.write(sDoc);
</script>

Thank you for your consideration.

View 17 Replies


ADVERTISEMENT

JQuery :: Load One Thing Then Another?

Jan 27, 2010

I have a big dropdown box with lots of items in it. It takes about 5 seconds to load in IE6. How can I use jQuery to load rest of the page, and then load the dropdown last? Right now, the dropdown load freezes the entire page until it loads.

View 3 Replies View Related

JQuery :: Unable To Do More Than One Thing With Datepicker?

Feb 17, 2011

it seems like an amazing tool once I figure out what I'm doing wrong. I'm using the awesome datePicker plugin, but am just not getting something right. I can't seem to be able to get datepicker to do more than one thing.To help myself figure out what Im doing wrong, I created a very simple example:

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/base/jquery-ui.css" type="text/css" media="all" />

[code]....

View 2 Replies View Related

Remove Attribute - Loading An <img> Tag With One Thing Or Another

May 24, 2011

Under PHP control, I am loading an <img> tag with one thing or another. I'm trying to work my way towards not changing the actual tag beyond what is already there (don't mess with the HTML).

The HTML is:

Code:

I am switching the image src path to something totally different. A such, I need to have the browser remove the alt and title attributes. I do this by loading the following in the {SRC} placeholder:

Code:

Using FF2.0.0.20, View Generated Output, I see that these attributes are indeed gone. Yet, the browser still shows (definitely) the alt attribute and (probably) the other attributes as well. I have also confirmed this happens with FF4.0.1-Portable.

View 6 Replies View Related

Strange Thing Happening With Onunload And Google

Jul 23, 2005

I have set up a disclaimer page for our public access PCs at our Libraries which has the following function:

function breach() {
alert("Proceeding beyond these Conditions is..................... If you have read the Conditions, scroll to the bottom and press the 'Yes I

agree' button.")
window.location="disclaim.htm"

and then in the body tag I have onunload=breach()
This works fine for all websites entered into the address bar except if

you enter www.google.com

What it is supposed to do is bring up the prompt and when you click on the OK button it will go back to the disclaimer page. They should only be able to get to the web by clicking on the 'Yes I
agree' button at the bottom of the disclaimer page. Does anyone out there know why google doesn't fire up the disclaim.htm page like all the other sites? It is very frustrating.

View 1 Replies View Related

Creating A Function Which Does The Same Thing For The Chosen Elements?

Jun 29, 2011

creating a function which does the same thing for the chosen elements.I have #design1 #design1servicetext and #design1servicebutton.

//Service hover//
$('#design1').mouseenter(function (){
$('#design1servicetext').css('background-position', '0 -91px')[code]....

How can I create a function, in which I have to choose 3 divs to do the animation?

A function like ,animatebg('#design1','#design1servicetext','#design1servicebutton');

View 1 Replies View Related

JQuery :: Script Running On Joomla With Php Type Thing?

Jul 15, 2009

basically i have this menu system which works using a couple of jquery scripts it all works fine etc, but now i am porting my site into a joomla design ( dont ask why just a challange )at the moment i have a module on the left which has my menu in and on the right is another module which loads the content depending on the outcome of the script:at the moment what ihave done is not the finished product as i would like to make sure that this will work before moving to the next part of my scriptbefore i go on and on and on ill show you what i have:

$(document).ready(function(){
$('ul.submenu>li a').click(function() {
$("div#defaultStuff").fadeOut("slow");

[code]....

View 1 Replies View Related

Doesn't For Loop Display The Right Thing To Text Area?

Nov 5, 2011

So I am working on a project to take an integer that the user gives, and then get all the squares and cubes of all the numbers before that to the number given. It displays it in a text area. Maybe I am just lost for the moment, but It just prints the number that I give with the square root and cube instead of starting from 1, and ended on the integer I give.

[Code]...

View 3 Replies View Related

JQuery :: Autocomplete - Simulate A Select Box Where Displayed Value Is One Thing And Submitted Value Is Another?

Oct 5, 2009

how to use the autocomplete jQuery plugin best to my needs. I'm looking to replace a select box with the Autocomplete plugin, but not quite sure how to accomplish this. In my select box, I have the option that is displayed is not the same as the data that is submitted.
ex: <option value="123">This is Displayed </option> However, with the autocomplete, since it is using a textbox, the values that are displayed, are submitted. Do I have to hack around using hidden fields to accomplish this type of behaviour?

View 1 Replies View Related

Create An Array Sort Of Thing To Convert The Country Name's To Continent?

Dec 21, 2010

If you've seen from my previous posts in this forum, you may have noticed that i'm a newbie when it comes to javascript, anyway. I'm trying to create an array sort of thing to convert the country name's to continent, and set it as a cookie. I spent all that time writing a PHP script for this same thing only to find out that my webhost does not have the maxmind apache module. I also don't know how to get the value of the country from a javascript function.

PHP Code:
function country_to_continent( $country ){$continent = '';if( $country== 'AF' ) $continent ='AS'; --CUT OFF DUE TO TEXT LIMIT, FIND THE FULL CODE HERE: http://infinitymedia.pastebin.com/7WWDeyVT return $continent;}

[Code]...

View 9 Replies View Related

Autocomplete AKA Google Suggest Made - Whats The Best Thing To Call Database Or Xml

Mar 28, 2009

So I have a nice little hand rolled Ajax call to my server pulling a list from the database and displaying it in a drop down list dependant on the user input. Aka Google suggest. I am wondering if the quickest way to do this is to call the database each time with Ajax and search the results with the input, or to write an xml from the database and search that. Then when the Database is updated rewrite the xml file.

Am I underestimating MYSQL again? Or not, and I feel it would be good practice to write the xml file because it will essentially mean a lot less database calls. But I don�t know how fast searching an xml file would be in comparison to a db call. The results from the database are say 500 entries anywhere between 10 - 100 characters each. I want to know A. The best way to do this B. Lets say the site will have pretty high traffic so I am looking for it to be as tweeked as possible. I can test but thought at the end of my week it was worth seeing what peoples advice is.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved