JavaScript: 위치.새 창/탭에서 여는 href를 선택하십시오.
서드파티 개발자의 JavaScript 파일을 가지고 있습니다.에는 현재 페이지를 대상으로 대체하는 링크가 있습니다.이 페이지를 새 탭으로 열고 싶습니다.
지금까지 제가 알아낸 건 다음과 같습니다.
if (command == 'lightbox') {
location.href="https://support.wwf.org.uk/earth_hour/index.php?type=individual";
}
누가 나 좀 도와줄래?
window.open(
'https://support.wwf.org.uk/earth_hour/index.php?type=individual',
'_blank' // <- This is what makes it open in a new window.
);
사용하고 싶은 경우location.href
팝업 문제를 피하기 위해 빈칸을 사용할 수 있습니다.<a>
참조 후 javascript를 사용하여 클릭합니다.
HTML에서와 같은 것
<a id="anchorID" href="mynewurl" target="_blank"></a>
그런 다음 다음과 같이 javascript를 클릭합니다.
document.getElementById("anchorID").click();
window.open 대신 순수 js.
let a= document.createElement('a');
a.target= '_blank';
a.href= 'https://support.wwf.org.uk/';
a.click();
다음으로 작업 예를 나타냅니다(스택오버플로우 스니펫은 오픈할 수 없습니다).
를 사용하여 새 창에서 열 수 있습니다.window.open('https://support.wwf.org.uk/earth_hour/index.php?type=individual');
. 새 탭에서 현재 페이지를 열고 현재 페이지와 새 페이지를 모두 얻을 수 있도록 스크립트를 2개의 탭으로 열고 실행할 스크립트를 모두 낮춥니다.
로케이션의 사용방법.href 는, 같은 Web 페이지의 현재의 URL 를 새로운 URL(https://support.wwf.org.uk/earth_hour/index.php?type=individual)로 치환합니다.
새 탭을 열려면 다음과 같이 사용할 수 있습니다. if (명령 == 'lightbox') { window.open https://support.wwf.org.uk/earth_hour/index.php?type=individual", '_blank'; }
예를 들어 다음과 같습니다.
$(document).on('click','span.external-link',function(){
var t = $(this),
URL = t.attr('data-href');
$('<a href="'+ URL +'" target="_blank">External Link</a>')[0].click();
});
작업 예
또한 다음과 같은 매개 변수를 사용하여 액션 메서드를 호출하는 새 탭을 열 수도 있습니다.
var reportDate = $("#inputDateId").val();
var url = '@Url.Action("PrintIndex", "Callers", new {dateRequested = "findme"})';
window.open(window.location.href = url.replace('findme', reportDate), '_blank');
언급URL : https://stackoverflow.com/questions/5141910/javascript-location-href-to-open-in-new-window-tab
'itsource' 카테고리의 다른 글
MySQL foreign_key_checks는 데이터베이스 전체에 영향을 미칩니까? (0) | 2022.11.14 |
---|---|
긴 쿼리를 쓰지 않고 모든 GraphQL 유형 필드를 쿼리하려면 어떻게 해야 합니까? (0) | 2022.11.14 |
@ComponentScan 주석을 사용하여 여러 경로를 스캔하려면 어떻게 해야 합니까? (0) | 2022.11.14 |
레퍼런스 요건setuptools setup.py 파일의 install_displays kwarg에 대한 txt (0) | 2022.11.14 |
MySQL에서 날짜/시간에서 시간을 빼는 방법 (0) | 2022.11.14 |