Java Script to redirect root site

Copper Contributor

Hi there,

 

let's say I use the domain abc.sharepoint.com. After entering this address, the "root site" will open for me. In addition to this site, I created an Intranet site at abc.sharepoint.com/sites/intranet.

 

I wanted to be redirected to abc.sharepoint.com/sites/intranet after entering abc.sharepoint.com in the browser.

 

Since the root website is in the "old" design, where I didn't figure out how to do this according to the instructions, I put the recommended script on the start page:

 

<script>
function corpRedirectPage() { 
	var urlParams = new URLSearchParams(window.location.search);
	var stay = urlParams.get('stay');
	
	if (stay === 'true') { 
		return; 
	}
	
	window.setTimeout(function() { 
		window.location.href = 'https://contoso.sharepoint.com/sites/news'; 
	}, 1500); 
} 

_spBodyOnLoadFunctionNames.push("corpRedirectPage");
</script>

 

I didn't change the target address to abc.sharepoint.com/sites/intranet the first time I used it, which caused me to be redirected to "contoso" every time I load the abc.sharepoint.com.

 

Even if I now insert a new script with the correct address, only the first "contoso" is still functional and it numbers the new javascripts.

Snímek obrazovky 2023-05-25 135415.pngSnímek obrazovky 2023-05-25 135524.png

Where can I view these applied JavaScripts on Sharepoint so that I can delete them and leave only the correct ones?

 

Thank you

Klara

0 Replies