Ibn_Hayyal Ibn_Hayyal - 8 months ago 55
Javascript Question

Code HTML into JavaScript code

I need to write some HTML code inside JavaScript


<!--start ramadan-->
<section id="ramadan" style="min-width:1200px">
<div class="container">
<div class="baner">
<div class="page">
<div class="slider">
<div class="slider-wrapper theme-default">
<div id="slider" class="nivoSlider">
<img src="royamotion2015/img/img/001.jpg" title=""/>
<img src="royamotion2015/img/img/002.jpg" alt="" title="" />
<img src="royamotion2015/img/img/003.jpg" alt="" data=""-transition="slideInLeft" />
<img src="royamotion2015/img/img/004.jpg" alt="" title="#htmlcaption" data=""-transition="slideInRight" />
<div id="htmlcaption" class="nivo-html-caption">
<strong></strong> <em> the code in view-source this page </em>
<a href="#"></a>.
<!--end ramadan-->

How can I write code like this JavaScript?



I think you're asking how to put that piece of code inside HTML...?

If so, it's easy. Put <script> tags inside your html:

    function url() { 
        var x = window.location.pathname; 
        if  (x=="/index/index.php") { 


And your JavaScript code will work.

If you're saying you need to write your whole page in JavaScript, which, in my brain, is crazy, then you have to use document.write(); and write each line of code:

    document.write("<section id=\"ramadan\" style=\"min-width:1200px\">");
    document.write("<div class=\"container\">");
    etc. etc.