locked
Add javascript to a hyperlink in a Sharepoint hyperlink column RRS feed

  • Question


  • Hi All,

    I have a list in sharepoint 2010. One column has type as hyperlink or picture. Among all of the hyperlinks available in list data, on click of one particular hyperlink i want to add a javascript function.

    Is there any client side solution of doing this? Else what is the best way to do this?

    My requirement: In list data when i click on a particular hyperlink, it should be validated for authorization based on type of user.

    e.g. We have two type of users with emp id ranging 1001-1999 and 7001-7999. Now for first category, when the user click on hyperlink it should show an alert message, "this form is not available for these users". For others it should be redirected to that URL.

    Thanks,

    Rudra

    Wednesday, July 4, 2012 8:06 PM

Answers

  • Create another page, which will have the validation on its page load.

    And the redirection logic.

    Add this page url in your hyperlink column.

    When user will click on this link, will be redirected to this validation page, where user will be validated.


    Thanks, Neha Navale

    • Marked as answer by Kamal Kochar Thursday, July 12, 2012 11:26 AM
    Thursday, July 5, 2012 5:15 AM

All replies

  • Hello!

    Hyperlink columns can't contain non url data, such as javascript.

    But you can use Calculated or MultilineText (with formatting) columns.


    My contributions: SharePoint 2010 Solution Installer

    • Proposed as answer by Chris Grist Thursday, July 5, 2012 1:35 AM
    Wednesday, July 4, 2012 8:24 PM
  • Create another page, which will have the validation on its page load.

    And the redirection logic.

    Add this page url in your hyperlink column.

    When user will click on this link, will be redirected to this validation page, where user will be validated.


    Thanks, Neha Navale

    • Marked as answer by Kamal Kochar Thursday, July 12, 2012 11:26 AM
    Thursday, July 5, 2012 5:15 AM
  • hi,

    you can add a javascript code in your DisplayForm.aspx / EditForm.aspx forms. On load to verify user rights(ranging). If reange is not valid, redirect to back page (eq. List view page)

    Thursday, July 5, 2012 6:04 AM