使用JavaScript的弹出菜单和页面重定向 [英] Popup menu and page redirection using javascript

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

问题描述

我在母版页中有一个导航链接(Page1,PAge2等).当用户将鼠标悬停在导航栏中的ASP链接(第1页,第2页)上时,会显示一个弹出菜单(例如:添加,编辑,删除).当用户选择单击菜单项(例如:添加)时,将执行以下javascript.

I have a navigation links(Page1, PAge2, etc) in Master page. when user mouseover on the asp links(Page1, page2) in the navigation bar, a popup menu(ex: Add, Edit, Delete) is shown. when the user selects the menu item(ex: Add) clicked, the following javascript is executed.

window.location.pathname = Page1/Admin/xyz.aspx?action=add"





http://SiteName/page1/Admin/xyz.aspx?action=add


页面已打开.以及具有上述路径的地址栏

当我再次在page1上进行鼠标悬停时,将显示弹出菜单,然后如果我在弹出菜单中单击编辑"

应该打开同一页面,但操作=编辑,即执行以下Java脚本.


page is opened. and the address bar having the above mentioned path

when I again do the mouseover on the page1 , the popup menu is shown, then if I clicked "Edit" in popup menu

the same page should be opened but the action = edit i.e the following java script is executed.

window.location.pathname = Page1/Admin/xyz.aspx?action=edit"



但是页面地址栏以以下方式显示

显示



but the page address bar is showing in the following way

window.location.pathname = Page1/Admin/xyz.aspx?action=add?action=add"

.

serverside

is shown.

in serverside

Request["action"]

中的值显示为"add?action = Edit"

为什么即使页面不一样,通过链接传递的数据也会继续用于其他地址?

我在这里做错什么吗?请帮助我...

value is shown as "add?action=Edit"

why the data passed along with the links is continuing for other address also, even if the page is not the same?

am i doing any mistake here? please help me...

推荐答案

KishoreT写道:
KishoreT wrote:

为什么数据传递即使页面不同,链接也会继续指向其他地址?

why the data passed along with the links is continuing for other address also, even if the page is not the same?



尽管您尚未发布解析或形成导航URL的代码,但从您的问题中可以明显看出,您没有重新设置要附加到基本URL的querystring变量/参数.

您保留要导航的URL,并根据添加/编辑/删除选择继续进行操作,并将该值附加到基本URL.在追加时重置查询字符串参数.重置将删除旧值.



Though you have not posted the code that parses or forms the navigation URL, it is clear from your issue that you are not re-setting the querystring variable/parameter that to append to your base URL.

You keep a URL to navigate and based on the add/edit/delete selection you go ahead and append that value to the base URL. while appending reset the query string parameter. Resetting would remove the old value.


您好,sandeep,

很抱歉,写这篇文章时我犯了那个错误.
实际的javascript是

hi sandeep,

sorry while writing the post i made that mistake.
the actual javascript is

window.location.pathname = Page1/Admin/xyz.aspx?action=edit



但是在地址栏中,它是在页面加载为
后查看的



but in the address bar it was viewed after the page load is

href="http://SiteName/page1/Admin/xyz.aspx?action=add?action=edit



所以我在服务器端收到



so I get an error that

Request["action"]

值的错误;


对不起,我没有得到你.重置查询字符串有什么意义?

我需要使用不同的操作值调用同一页面.

即使我调用了xyz.aspx页面以外的其他页面,也会发生错误.

我正在发布实际的javascript代码
< pre lang ="cs">函数RedirectRightFrame(Action)
{
开关(动作)
{
//项目
案例& quot; AddProject& quot ;:
//alert(window.location.pathname);
window.location.pathname =& quot; Project1/Admin/Projects.aspx?action = add& quot ;;
//document.loaction.href(&quot;Projects.aspx?action=add&quot;);
休息;
案例& quot; EditProject& quot ;:
window.location.pathname =& quot; Project1/Admin/Projects.aspx?action = Edit& quot ;;
休息;
案例& quot; DeleteProject& quot ;:
window.location.pathname =& quot; Project1/Admin/Projects.aspx?action = Delete& quot ;;
休息;
//角色
案例& quot; AddRole& quot ;:
window.location.pathname =& quot; Project1/Admin/Roles.aspx?action = add& quot ;;
休息;
case& quot; EditRole& quot ;:
window.location.pathname =& quot; Project1/Admin/Roles.aspx?action = Edit& quot ;;
休息;
案例&"DeleteRole&":
window.location.pathname =& quot; Project1/Admin/Roles.aspx?action = Delete& quot ;;
休息;

}
}</pre>


地址栏上的地址如下
< pre> http://localhost:13846/Project1/Admin/Roles.aspx?action = Edit?action = add</pre>

现在告诉我我需要重设以上代码中的地址吗?
sorry I didn''t get u. what is ment by resetting the query string?

I need to call the same page with different action value.

The error occurs even if I called other pages other than xyz.aspx page.

I am posting actual javascript code
<pre lang="cs">function RedirectRightFrame(Action)
{
switch(Action)
{
//Projects
case &quot;AddProject&quot;:
//alert(window.location.pathname);
window.location.pathname = &quot;Project1/Admin/Projects.aspx?action=add&quot;;
//document.loaction.href(&quot;Projects.aspx?action=add&quot;);
break;
case &quot;EditProject&quot;:
window.location.pathname = &quot;Project1/Admin/Projects.aspx?action=Edit&quot;;
break;
case &quot;DeleteProject&quot;:
window.location.pathname = &quot;Project1/Admin/Projects.aspx?action=Delete&quot;;
break;
//Roles
case &quot;AddRole&quot;:
window.location.pathname = &quot;Project1/Admin/Roles.aspx?action=add&quot;;
break;
case &quot;EditRole&quot;:
window.location.pathname = &quot;Project1/Admin/Roles.aspx?action=Edit&quot;;
break;
case &quot;DeleteRole&quot;:
window.location.pathname = &quot;Project1/Admin/Roles.aspx?action=Delete&quot;;
break;

}
}</pre>


The address at the address bar is as follows
<pre>http://localhost:13846/Project1/Admin/Roles.aspx?action=Edit?action=add </pre>

now tell me what i need to reset the address in the above code?


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

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