我需要一个帮助。这里我想假设用户当前在个人资料页面中( http://localhost/medilink/profile.php
)。当用户仅单击一个按钮时, profile.php
将替换为deal.php
,相应的页面会来。我需要使用click事件的这种情况,并更改URL获取新页面。请帮助我。
You can add this to your button :
// set the proper url
// relative path :
onclick="window.location.href = './deal.php'"
// absolute path :
onclick="window.location.href = '/medilink/deal.php'"
// other website :
onclick="window.location.href = '//google.com"
your button ("a" tag ? or "button" tag ?) becomes :
<button onclick="window.location.href = './deal.php'">my Button</button>
You can create a function and pass the url you want to redirect.
// JS:
function redirectURL(url) {
window.location.href(url)
}
// HTML:
<button onclick="changeURL('http://www.gooogle.com')"></button>
Following code snippet may help you.
$('button').click(function () { var arr = window.location.href.split('/'); arr[arr.length - 1] = 'deal.php'; var url = arr.join('/'); window.location = url; });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button>click here</button>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.