Click here to Skip to main content
15,888,330 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi,

I have some issues to combine JavaScript.

I have a link within the SharePoint Navigation which I do not have access to the
<a></a>
tag. This the reason being that I created a link to aspx page with the JavaScript below.

So what happens is click the link, open the apsx page, onload the JavaScript fire. The JavaScript opens a modal window that allows the user to upload a document to a document library.

Currently my code will just click the link again and the modal popup will loop. So first of all I need to only click the JavaScript once. Then the user should be redirected to the page where the upload link was initially clicked. This should be something like this,
window.location.history.go(-1)


XML
<a class="ms-addnew" id="idHomePageNewDocument"
href="http://site/Documents/_layouts/Upload.aspx?List={ListID}&amp;RootFolder=&"
onclick="javascript:NewItem2(event, &quot;http://site/Documents/_layouts/Upload.aspx?List={ ListID }&amp;RootFolder=&quot;);
javascript:return false;" target="_self">Upload new asset</a>

<script language="javascript">
function go()
    {
    document.getElementById("idHomePageNewDocument").click();
    }
window.onload = go;
</script>

I am not sure how to combine all of this code.
Please help!!
Posted

1 solution

I'm not quite clear on what it is you are attempting to do. However, I would recommend you research SharePoint 2010 Dialog Framework and JQuery.

http://blogs.msdn.com/b/vesku/archive/2010/02/25/how-to-sharepoint-2010-js-client-object-model-and-ui-advancements.aspx[^]

http://www.chaholl.com/archive/2010/11/17/using-the-dialog-framework-in-sharepoint-2010.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900