Results 1 to 3 of 3

Thread: How to convert multi-line HTM strings into characters and assign them to new variable

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,040

    How to convert multi-line HTM strings into characters and assign them to new variable

    I collected HTML data and how to convert it to a format supported by JS variables
    It is var htm=document.body.innerHTML
    If var htm2="<HTML><BODY" wrap " </HTMl>
    How about converting HTM's value to a string after HTML2?

    How to write in JS code?

    Code:
    htm=document.body.innerHTML
    htm2="<HTML><BODY" wrap " </HTMl>

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,040

    Re: How to convert multi-line HTM strings into characters and assign them to new vari

    like this? i will test

    Code:
    var htm1=document.body.innerHTML;
    function strtojscode(htmstr){return htmstr.replace(/\\/g,"\\\\").replace(/\\/g,"\\/").replace(/\'/g,"\\\'").replace(/\"/g,"\\\"")}
    alert(strtojscode(htm1))

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,966

    Re: How to convert multi-line HTM strings into characters and assign them to new vari

    Is this a question about VB.NET or JavaScript?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width