javascript - 追加URL元素后面的文字 [英] javascript - append text after URL element
问题描述
有没有办法将某些东西添加到使用javascript的URL中?并删除前缀?
例如。 http://www.google.com/放入google.com.local /
concat()
方法用于连接两个或多个字符串。 此方法不会更改现有字符串,但会返回包含连接字符串文本的新字符串。在你的情况下:
var mystring = concat(http://www.google.com,.local) ;
并且从字符串中删除部分 - 使用 split()
方法将字符串拆分为一个子字符串数组,并返回新的数组。
提示:如果使用空字符串()作为分隔符,字符串在每个字符之间被分开。
注意: split()
方法也不会更改原始字符串。
Is there a way to append something to a URL using javascript? and to remove prefixes?
e.g. "http://www.google.com/" into "google.com.local/"
The concat()
method is used to join two or more strings.
This method does not change the existing strings, but returns a new string containing the text of the joined strings. In your case:
var mystring = concat("http://www.google.com",".local");
And for removing parts from string - use split()
method to split a string into an array of substrings, and returns the new array.
Tip: If an empty string ("") is used as the separator, the string is split between each character.
Note: The split()
method also does not change the original string.
这篇关于javascript - 追加URL元素后面的文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!