SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    new line error using javascript in a sharepoint cewp content editor web part

    I am having trouble adding a new line using javascript reference in SharePOint 2010 CEWP Content editor web part in IE8. The code below works until i try to add the new line.Has anyone had success with using the newline command in CEWPs? Where exactly do they go and how are they written? thanks dave (newbie)


    I have tried the following on their own lines and in a line of code

    \r\n;
    \n;
    and also the html equivalents

    <SCRIPT>

    var formLink2 = (location.href);


    var re2 = new RegExp(".*RootFolder=");

    var re1 = new RegExp("&GroupString.*TRUE");

    var myRelatives = formLink2.replace(re2, "");

    var myRelatives2 = myRelatives.replace(re1, "");

    alert(myRelatives2);


    var infoPathForm = "REDACTED\/_layouts\/FormServer\.aspx\?

    XmlLocation\=\/sites\/localresearch\/ConflictOfInterest\/1111111\.xml&OpenIn\=Browser&SaveLocation\=https\:\/

    \/REDACTED\/Miami\/ProjectManagement\/testName";



    document.write('Conflict of Interest Form'.link(infoPathForm)) ;

    // here is where I would like the break.
    document.write(infoPathForm);



    </SCRIPT>

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,785
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    the last browser where document.write served any purpose was Netscape 4.

    use innerHTML or the proper JavaScript DOM to output the content instead.

    When outputting to HTML a line break is created either using <br> if you use innerHTML or using the DOM call document.createElement('br');
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

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