我有以下功能function make(point, name, message, type, file, id, lat, lng)
我希望该函数将所有这些Javascript变量传递给一个php文件,当按下链接时该文件会在窗口中打开,我该怎么做?
最佳答案
window.open('path/to/php?point=' + point + '&name=' + name); // etc for all other vars
确保变量的值是urlsafe的,我用以下方法对它们进行urlencode:
encodeURIComponent(variable);
编辑您的评论
<a href="#" onclick="make(vars, go, here); return false;">Click me!</a>
但是,如果仅此而已,则最好在空白窗口中打开链接:
<a href="path/to/php?point=foo&etc=bar" target="_blank">Click me!</a>
我怀疑这取决于
make()
是否正在做其他事情而不是打开窗户?