javascript - 追加URL元素后面的文字 [英] javascript - append text after URL element

查看:106
本文介绍了javascript - 追加URL元素后面的文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将某些东西添加到使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆