Ibn_Hayyal Ibn_Hayyal - 4 months ago 24
Javascript Question

Code HTML into JavaScript code

I need to write some HTML code inside JavaScript

The HTML:

<!--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>
<div id="htmlcaption" class="nivo-html-caption">
<strong></strong> <em> the code in view-source this page </em>
<a href="#"></a>.
</div>
</div>
</div>
</div>
</div>
</section>
<!--end ramadan-->


How can I write code like this JavaScript?

http://jj.org.sa/aa/1.html

Answer

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:

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

        } 
    }
</script>

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:

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