locked
dont work JS in aspx RRS feed

  • Question

  • I use Sharepoint Designer 2007.

    When I add JS code in EditForm.aspx and NewForm.aspx in new survey, do not get any result.

      Add the following line

    document.getElementsByTagName('Table').item(0).out­erHTML=document.getElementsByTagName('Table').item­(0).outerHTML.replace(/&lt;/g,'<').replace(/&gt;/g­,'>');

    to

    <script  id="onetidPageTitleAreaFrameScript">
    document.getElementById("onetidPageTitleAreaFrame").className="ms-areaseparator";
    </script>

    and when I try to click on a hyperlink  <script  id="onetidPageTitleAreaFrameScript">, I get a message : "code hyperlink not found"

     

     


    • Moved by Mike Walsh FIN Monday, July 4, 2011 9:13 AM customization (SPD) rather than programming (From:SharePoint - Development and Programming (pre-SharePoint 2010))
    Monday, July 4, 2011 7:13 AM

Answers

  • Hi ,

    Modify your javascript function:

    <script type="text/javascript">
    function onetidPageTitleAreaFrameScript()
    {

      // your logic


    }
    </script>

    then call using onclick or href event like below:

    <a onclick='onetidPageTitleAreaFrameScript();'>xyz</a>

     


    thanksArup MCTS - SharePoint

    Play Sudoku Online
    • Marked as answer by Wayne Fan Monday, July 18, 2011 6:06 AM
    Monday, July 4, 2011 8:35 AM
  • Hi dreamam,

    I have a test in my local with the code you provide:

    <script id="onetidPageTitleAreaFrameScrip">
    document.getElementById("onetidPageTitleAreaFrame").className="ms-areaseparator";
    document.getElementsByTagName('Table').item(0).outerHTML=document.getElementsByTagName('Table').item(0).outerHTML.replace(/&lt;/g,'<').replace(/&gt;/g,'>');
    </script>

    The code is added after the line:

    <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server"> in EditForm.aspx.

    The result is: the web part of “Respond to this Survey” is hidden.

    As you “click on a hyperlink <script  id="onetidPageTitleAreaFrameScript">”? The “id” in this place is a field of current script code.

    Best Regards,

    • Marked as answer by Wayne Fan Monday, July 18, 2011 6:06 AM
    Tuesday, July 5, 2011 10:02 AM
    Moderator

All replies

  • Hi ,

    Modify your javascript function:

    <script type="text/javascript">
    function onetidPageTitleAreaFrameScript()
    {

      // your logic


    }
    </script>

    then call using onclick or href event like below:

    <a onclick='onetidPageTitleAreaFrameScript();'>xyz</a>

     


    thanksArup MCTS - SharePoint

    Play Sudoku Online
    • Marked as answer by Wayne Fan Monday, July 18, 2011 6:06 AM
    Monday, July 4, 2011 8:35 AM
  • Hi, Arup R

    I have create function in EditForm.aspx and NewForm.aspx?

    Because I must get a result:

    <script id="onetidPageTitleAreaFrameScrip">
    document.getElementById("onetidPageTitleAreaFrame").className="ms-areaseparator";
    document.getElementsByTagName('Table').item(0).outerHTML=document.getElementsByTagName('Table').item(0).outerHTML.replace(/&lt;/g,'<').replace(/&gt;/g,'>');
    </script>

    You mean insert this logic to function? and what is xyz ?


    Monday, July 4, 2011 8:59 AM
  • Hi dreamam,

    I have a test in my local with the code you provide:

    <script id="onetidPageTitleAreaFrameScrip">
    document.getElementById("onetidPageTitleAreaFrame").className="ms-areaseparator";
    document.getElementsByTagName('Table').item(0).outerHTML=document.getElementsByTagName('Table').item(0).outerHTML.replace(/&lt;/g,'<').replace(/&gt;/g,'>');
    </script>

    The code is added after the line:

    <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server"> in EditForm.aspx.

    The result is: the web part of “Respond to this Survey” is hidden.

    As you “click on a hyperlink <script  id="onetidPageTitleAreaFrameScript">”? The “id” in this place is a field of current script code.

    Best Regards,

    • Marked as answer by Wayne Fan Monday, July 18, 2011 6:06 AM
    Tuesday, July 5, 2011 10:02 AM
    Moderator
  • 'xyz' is your link on which onclick event wiill work. & definitely write your JS function inside PlaceHolderMain.
    thanksArup MCTS - SharePoint

    Play Sudoku Online
    Thursday, July 7, 2011 6:31 AM