1

I am quite new to both HTML5 and Javascript. I want to set an editable string in Javascript which will hold HTML5 code so it can be edited from Javascipt interface. Then I want to take this string to another HTML5 page and show it as a preview. So that the string edited in Javascript interface will be seen as a result right next to it in a small HTML5 preview screen.

How to refer to the string in JS script from HTML5 and use it as if it is a part of HTML5 code?

Hope I could explain myself. Thanks in advance.

Clifford
  • 88,407
  • 13
  • 85
  • 165
AnilDemir
  • 19
  • 5

1 Answers1

1

You can insert HTML dynamically using jQuery. Check out this example for more info: What is the correct way to write HTML using Javascript?

I'm sorry if this isn't what you're asking. I'm not sure I fully understand the question. Hope this helps!

Community
  • 1
  • 1
BCza
  • 330
  • 2
  • 13
  • thanks for response. what document.write() does is this: so you see the text on the screen and you can take a string or any text from other script or document. but I want to do this: so it wont show as text but as html5 code. I dont think so but can document.write() do this? – AnilDemir Jul 15 '14 at 14:47
  • Sorry, I misread the linked response. If you check the answer on the post I linked, he shows how to use jQuery to add dynamic html to a specific node in the DOM. Are you asking how to have an html preview of a different page on the same page? Also, I'll update my answer so it isn't as confusing. – BCza Jul 15 '14 at 14:51
  • Yes this is what I want. I'm sorry, guess I was distracted, couldn't understand the use of document.write(). Now I get it. Here is an example of how I want to use it https://developer.mozilla.org/en-US/docs/Web/API/document.write Thanks! – AnilDemir Jul 15 '14 at 18:33