Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

so I tried to add a little horizontal menu to a wiki-site and wanted one of the links to open in a modal Dialog (a contact form). Every time I try to add it about the UI, sharepoint removes the link. Same in SP Designer.

Here's the syntax I'm using:

<a onclick="javascript:SP.UI.ModalDialog.ShowPopupDialog('url/contactform.aspx');">Contact Form</a>

I don't have a clue why it's not working, it's the same syntax I'm using for one of my webpart-buttons and it works like a charm there, would be great to have some ideas on this :)

update: I tried it with href attribute, too. same behaviour, sp removes the attribute :(

share|improve this question
add comment

3 Answers 3

up vote 3 down vote accepted

In Wiki pages SharePoint will always remove scripts, or calls to javascript. One way to overcome is to use jQuery :live functions in a function in a separate .js file stored somewhere in a Document library and added in page via a CEWP, but then add an ID to your Link item.

Yes, it sounds like overkill, but that would be one way to do it.

share|improve this answer
    
thanks, i'll try this out :) –  Dominik Feb 8 '13 at 13:32
add comment

I suppose, SharePoint checks the validity of the link and removes it. It doesn't check the validity in custom webparts. You could try to repclace onclick with href attribute. Hope it helps. Say if it doesn't.

<a href="javascript:SP.UI.ModalDialog.ShowPopupDialog('url/contactform.aspx');">
Contact Form</a>
share|improve this answer
    
sry, will update my question. I tried that, too. Same behaviour :( –  Dominik Feb 8 '13 at 13:19
add comment

The first hint from Anatoly was the key for me. Sadly it took 3 hours to find out.

Just insert a new Content editor webpart and insert the code their. When you change the appearance and hide the frame it looks like it is directly inserted on the wiki site.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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