0

I have found how to open any link in modal view thanks to the JS OpenPopUpPage* on publishing pages.
I would like to use this also with the links I have in my page layout (created by snippets), so that a link is always opened in modal view (in my case I have a "more info" link on every page, but its URL is different depending on the page).
With a normal link I use a snippet of a hyperlink column in the page layout, but if I am using the JS link format I did not success. I have created a text column with the JS link (with a calculated column)

< a href="#" onclick="OpenPopUpPageWithTitle('myDynamicURL',null,width,height,'title ')">My link</a>'

But when I try to use it programmatically (in a snippet), it does not work, SP does not interpretate it as a valid link. Does anybody has a solution or a workaround for it?

HTML Code Rendered

<a href="#" onclick="OpenPopUpPageWithTitle('myURL',null,800,600,'Topics and discussions')">DISCUSSIONS</a>..... 

a no working one (coming from a snippet):

<div data-name="Page Field: MoreInfoJava">&lt;a href=&quot;#&quot; onclick=&quot;OpenPopUpPageWithTitle(&#39;<a href="MyURL',null,800,700,'More">myURL&#39;,null,800,700,&#39;More</a>&nbsp;info‌​&#39;)&quot;&gt;More info&lt;/a&gt; </div>
9
  • Your requirement is not clear. Please rephrase. Commented Dec 17, 2014 at 14:23
  • Hope now is more clear
    – Marpio
    Commented Dec 17, 2014 at 14:31
  • Can you post how the link is rendered in the browser (HTML). Commented Dec 17, 2014 at 14:33
  • a working one: <a href="#" onclick="OpenPopUpPageWithTitle('myURL',null,800,600,'Topics and discussions')">DISCUSSIONS</a>..... a no working one (coming from a snippet): <div data-name="Page Field: MoreInfoJava">&lt;a href=&quot;#&quot; onclick=&quot;OpenPopUpPageWithTitle(&#39;<a href="MyURL',null,800,700,'More">myURL&#39;,null,800,700,&#39;More</a>&nbsp;info&#39;)&quot;&gt;More info&lt;/a&gt; </div>
    – Marpio
    Commented Dec 17, 2014 at 15:05
  • sorry but in comment area I cannot format the text
    – Marpio
    Commented Dec 17, 2014 at 15:06

1 Answer 1

0

A hyperlink column will let you create a hyperlink, but it will block your javascript injection for security reasons (and rightly so - otherwise anyone could write any amount of javascript and have it execute on the page).

There are many ways to do what I think you are trying to do. I recommend using jQuery to rewrite your links after the page loads.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.