开发者

passing subdomain to a variable then creating new url

HI, I am nearly there I think but am struggling to put the final bits in place.

I am trying to look up the the subdomain of a number of different envoronments and pass the subdomain as a variable to prefix a url called via an onclick event. This is all delivered through an xsl transformation.

I am just getting the domain passed to the link at present. Any tips on how to make this work or write the code in a better way greatly appreciated.

            <xsl:text disable-output-escaping="yes">        
                            <![CDATA[
                            <script type="text/javascript">

                                function enironment()
                                {       
                                    if (window.location.host.toLowerCase() === 'www.mydomain.com') {
                                                    SsoServer = "https://sso.mydomain.com";
                                    }
                                    else{
                                    var sub_domain = window.location.split('.')[0].split('//')[1];
                                    SsoServer 开发者_StackOverflow社区= "https://" + sub_domain + "sso.mydomain.com";
                                    }                           

                                    top.location.replace(SsoServer);                                            
                                }

                            </script>]]>

                        </xsl:text>

                                <a href="#" onClick="javascript:enironment()" title="Sign in">Sign
                                    in</a>


Might be because you have three equals signs instead of two here:

if (window.location.host.toLowerCase() === 'www.mydomain.com') {

Should be:

if (window.location.host.toLowerCase() == 'www.mydomain.com') {
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜