使用 Javascript 重定向页面 [英] Using Javascript to redirect a page

查看:55
本文介绍了使用 Javascript 重定向页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码

<input type="image" src="/wp-content/themes/happy/images/add-to-cart.png" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button" onclick="alert('Cart Updated');"/>

如何让代码重定向到example.com"而不是显示警报"?

How do I get that code to redirect to "example.com" instead of displaying the "alert thing?

推荐答案

<input type="image" src="/wp-content/themes/happy/images/add-to-cart.png" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button" onclick="window.location='http://example.com';"/>

注意 url 周围的单引号.

Note the single quotes around the url.

这篇关于使用 Javascript 重定向页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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