0

I have a custom webpart which acts as a 'dashboard' showing product information on a subsite, and it needs to include a direct link to another subsite within the same site collection. Whenever I try to include a link, however, Sharepoint appends it to the existing site url.

The webpart uses ReactJS and REST to recall product information from a list on the parent site. The js file is referenced to via a Content Editor web part.

For example, I have the subsite "Project1" that I want to link to the "Project1A" subsite. Using javascript, I set up the html to render as:

<a href="https://sitename.sharepoint.com/sites/sitecollection/Project1A">

But the actual link that renders when the page loads reads: sitename.sharepoint.com/sites/sitecollection/Project1/"https://sitename.sharepoint.com/sites/sitecollection/Project1A"

What is the correct way to add a direct link?

To help clarify, here's a snippet of my code where the link is generated (the URL is changed to protect my business' identity:

render(){
        debugger;
            return ( 
                <div>    
                {this.state.items.map(function(item,key){ 
                console.log(item)
                var editLink = '"https://sitename.sharepoint.com/sites/sitecollection/project1A"';
                console.log(editLink)
                    return (
// Custom HTML to render Product Info Panel
                    <div style={divContainer} key={key}>
                      <div style={divProductinfo}>
                        <h1 style={h1Producttitle}>{item.Title}</h1>
                        <a href={editLink}><div style={divEdit}>Edit</div></a><br></br>
  • change it to <a href="https://sitename.sharepoint.com/sites/sitecollection/Project1A"> – Gautam Sheth Oct 24 '17 at 10:49
  • Sorry, I was using shorthand for the example. "https://" is already included at the beginning of my link in the anchor tag. I've edited the original post to be more accurate. – Mark E Oct 24 '17 at 10:50
0

The method you are using is correct! Its just that sometimes, SharePoint overrides the HTML behavior. Clear the browser caches, and try changing the HTML back again to original as you've written as show below, when you encounter the problem again This will be a one time activity.

<a href="https://sitename.sharepoint.com/sites/sitecollection/Project1A">

This should solve the problem.

Hope this helps!

  • Sorry, but this doesn't seem to help. The problem persists across browsers, and despite a cache clear. – Mark E Oct 24 '17 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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