duanju9104 2014-10-28 01:58
浏览 491
已采纳

通过Javascript location.reload传递变量(true)

I have a webpage with a really large MySQL query as the result. The query is changed depending on the user, so it will be different for each person. I am trying to provide a method of resorting the query by making the headers into clickable links.

My query results page is written in PHP and HTML for the most part.

For each column header, I have the following:

echo "<th id='frame_data_table'>
    <a href='javascript:location.reload(true)'>XBox 360 Command</a>
</th>";

On clicking the column header link, the page will reload using the javascript in the a href. This is the most successful way I've been able to get my webpage to reload with all of the query information.

All I need to do now is figure out how to pass another variable upon clicking the header link. I have tried to do syntactical variations of something like

echo "<th id='frame_data_table'>
    <a href='javascript:location.reload(true)+?var1=command_column'>XBox 360 Command</a>
</th>";

with no success. Once I get the variable to pass, I will just grab it with $_GET[''], no problem.

Any advice? It's worth noting that after extensive googling, I saw a lot of location.href. This does not reload my page, and in fact all it really does (in Chrome, anyway) is load a page with just the text url of the page I want.

Is there any way to pass a variable in the url using javascript's location.reload()? Thanks in advance.

-Anthony

UPDATE: Solution

I asked a similar question and was able to obtain a solution. See the link here. The solution is fully explained in the bottom of the question.

  • 写回答

1条回答 默认 最新

  • dowjgrm6787 2014-10-28 02:02
    关注

    Using

    location.href = location.href + "?var1=command_column"
    

    will redirect you to the current URL with the added parameter, i.e. the page will be effectively reloaded.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler