Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Sep 2002
    Location
    Charlotte
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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')

  • #2
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    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
    Last edited by martin_narg; 04-15-2005 at 05:31 PM. Reason: Code cleanup
    "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

  • #3
    New Coder
    Join Date
    Sep 2002
    Location
    Charlotte
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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>

  • #4
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    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
    Last edited by martin_narg; 04-22-2005 at 11:05 AM.
    "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

  • #5
    New Coder
    Join Date
    Sep 2002
    Location
    Charlotte
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excellent.........many thanks!

    That should work just fine.

    Dan


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •