Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-15-2005, 09:26 AM   PM User | #1
dan18088
New Coder

 
Join Date: Sep 2002
Location: Charlotte
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
dan18088 is an unknown quantity at this point
Can I use a wildcard for this?

It is not always default.aspx but is always *.aspx

var link = location.href

var regEx = new RegExp ('default.aspx', 'gi') ;

settingslink = link.replace(regEx, '_layouts/Intranet/settings.aspx')
dan18088 is offline   Reply With Quote
Old 04-15-2005, 05:17 PM   PM User | #2
martin_narg
Regular Coder

 
martin_narg's Avatar
 
Join Date: Jul 2002
Location: Chamonix, France
Posts: 600
Thanks: 1
Thanked 3 Times in 3 Posts
martin_narg is an unknown quantity at this point
Not quite sure what you mean mate but this will grab the domain and pop your folder/file afterwards:
Code:
<script>
function settingsLink() {
	var strSettingFolderAndFile = "/_layouts/Intranet/settings.aspx";
	var rExp = /http\:\/\/(.*)\/(.*)/i;
	var strSettingsLink = document.location.href.replace(rExp, "http://$1" + strSettingFolderAndFile);
	//var strTest = document.location.href.replace(rExp, "Domain: $1\nFolder (if file is in a folder) and file: $2);
	alert( strSettingsLink );
}
</script>
Hope this helps, I've left in strTest so you can see what the regular expression is bringing out of the document.location.href string.

m_n
__________________
"Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
-Tommy Cooper

Last edited by martin_narg; 04-15-2005 at 05:31 PM.. Reason: Code cleanup
martin_narg is offline   Reply With Quote
Old 04-15-2005, 10:32 PM   PM User | #3
dan18088
New Coder

 
Join Date: Sep 2002
Location: Charlotte
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
dan18088 is an unknown quantity at this point
I will try it but not sure if it will work....

I have a custom top navigation bar at the top of my Intranet and it loads menu options based on what you put in the menu_data.js file. The problem is SharePoint (A MS Portal App) which has 3 links for site settings and on the standard microsoft navbar, it knows if the is http://sharepoint/sites/maketing or http://sharepoint/sites/marketing/projects or even http://sharepoint/sites/sales (the file name is something .aspx) so if I could find *.aspx and replace it with the current url the user is at....that would be great! I was using the below code and it worked great until I realized that not all pages are called default.aspx

<html>
<head>
<script>
var link = location.href

var regEx = new RegExp ('default.aspx', 'gi') ;

link = link.replace(regEx, '_layouts/1033/settings.aspx')

document.write(link)

</script>
</head>
</html>
dan18088 is offline   Reply With Quote
Old 04-22-2005, 10:44 AM   PM User | #4
martin_narg
Regular Coder

 
martin_narg's Avatar
 
Join Date: Jul 2002
Location: Chamonix, France
Posts: 600
Thanks: 1
Thanked 3 Times in 3 Posts
martin_narg is an unknown quantity at this point
Aaaah my bad - apologies.

This single line should sort you out:
Code:
var strLink = location.href.replace(/\/*\.aspx/gi, '/_layouts/1033/settings.aspx');
Hope this is right for you. It matches a / then any number of characters (the *) then .aspx and replaces with /_layouts/1033/settings.aspx

m_n
__________________
"Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
-Tommy Cooper

Last edited by martin_narg; 04-22-2005 at 11:05 AM..
martin_narg is offline   Reply With Quote
Old 04-22-2005, 11:02 AM   PM User | #5
dan18088
New Coder

 
Join Date: Sep 2002
Location: Charlotte
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
dan18088 is an unknown quantity at this point
Excellent.........many thanks!

That should work just fine.

Dan
dan18088 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:33 AM.


Advertisement
Log in to turn off these ads.