我正在尝试创建一个完整的Div可点击并链接到一个新标签。到目前为止,我已经使div可点击并发送到具有此代码的新链接
$(document).ready(function(){
$('.wish-list').click(function(){
location.href = 'https://link.com'
})
});
这可以将您所在的页面发送到链接,但我想执行相同的操作,但打开一个新标签。
非常感谢您的帮助。
答案 0 :(得分:3)
您可以使用window.open:
window.open("http://link.com", "_blank");
答案 1 :(得分:2)
您可以使用:
window.open('url', '_blank');
答案 2 :(得分:1)
使用此而不是location.href
window.open(strUrl, strWindowName[, strWindowFeatures]);
实施例
window.open('http://www.google.com','_blank');
答案 3 :(得分:0)
您需要使用import pyaudio
import speech_recognition as sr
def callback(recognizer, audio):
# received audio data, now we'll recognize it using Google Speech Recognition
try:
print("Google Speech Recognition thinks you said " + recognizer.recognize_google(audio))
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition service; {0}".format(e))
r = sr.Recognizer()
m = sr.Microphone()
with m as source:
r.adjust_for_ambient_noise(source)
stop_listening = r.listen_in_background(m, callback)
import time
for _ in range(100): time.sleep(0.1)
stop_listening()
print("over")
while True: time.sleep(0.1)
。由于沙盒,下面的代码段无法在Stack Overflow代码段环境中使用,但您可以看到它工作 here :
window.open()
$(function(){
$('.link').on("click", function(){
window.open(this.dataset.url);
});
});
.link {
cursor:pointer;
}
答案 4 :(得分:0)
试试这个
window.open('url', '_blank');