Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

How To Insert Code With Javascript


12 replies to this topic

#11 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 04 August 2009 - 08:06 PM

HTML as objectHow To Insert Code With Javascript

Hi :)

Being a novice in all the webdesign variations, I came upon a problem that might be very basic (sorry about this) but I've tried everything I could think of and still not closer to a solution.

Here's my problem:

I'm building a website that was requested to be formatted through tables.As part of the site, of course, there's a javascript dynamic accordion style menu.Due to the dimension of the web site (somewhere close to 300 pages butDue to increase 5 to 10 pages every forthnight), I didn't want to haveThe script in each page as the menu will be altering continuously, soCreated "menu.Htm" and pulled it into every page as an object.

<object type="text/x-scriptlet" border="0" width=200 height=650 data="menu.Htm">

So far so good, and while working from my disc all was working great.When the site was uploaded to the company's (foreign) server, IEDoesn't show the menu at all and Firefox opens the menu but all theLinks cointained in it open in the original object's bounding box.Before you all laugh, I'm trying to help my partner look good to hisBoss, I'm not a programmer and HTML was a kick when I was inHigh-school doing marquees for fun :(I might have to add some attribute to the "a" tag in the menu, but if so don'tknow which...

 Any ideas welcome, thanks for helping me



#12 iGuest

    Hail Caesar!

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,876 posts
  • Interests:Trap17 Free Web Hosting, No Ads

Posted 02 November 2009 - 10:39 AM

Problem is your code won't work if you use "</script> anyware in your "code" variable.For example :Var code "<script>alert('Now I'm broken');</script>" Don't ask me for an answer which works on this one, I've seen plenty try, but all answers escape the <script> tags which makes them useless. Fine if you're trying print the <script> tag to screen, not if you're trying to make it do something.  Sorry for responding to an old post, but just thought I might save someone the headache. 

 



#13 Guest_Hemant_*

  • Guests

Posted 05 August 2010 - 05:54 AM

View Postmizako, on 18 May 2005 - 08:01 AM, said:

Hi,
I have the next html page
<html>
<head>
<script>
<!--
function insertcode()
{
var code ="<p> blablabal babala babababab</p><h1>here comes header</h1><span>fadfafa<a href=\"fadfaf\">anchor</a>blalbababa</span>"
var myText = document.createTextNode(code);
document.getElementById("content").appendChild(myText);
}
-->
</script>
</head>
<body>
<div id="content">
</div>
<a href="javascript:insertcode()">Insert Code</a>
</body>
</html>
This code insert the data as text. The html tags are not treated like markup. I need to insert the code in a time. I mean i can not go tag per tag. (E.g. document.createElement("p")... )
Is there any method to insert a pice of html code into a div and keep it like code not like text in Javascript?
I hope you understand my problem. If not please tell me. Thanks in advanced for your help.

This function is really useful...

but this is for simple textareas. If you override textarea with tinymce text editor class. This function returns error.

Can someone suggest the possible solution to work with tinymce or or any other editor with textarea.

Quick reply would really be appreciated.

Thanks

Hemant




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users