The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Javascript confirmation box
I am trying to use the following script to create a Confirmation Popup box for my "Mark All Forums Read" link, but it isn't working.
In my Navbar template I placed the following at the top: Code:
<vb:literal> <script> <!-- function markAsRead() { var markRead= confirm("Do you really want to mark all forums as read?"); if (markRead== true) { window.location="forumdisplay.php?{vb:raw session.sessionurl}do=markread&markreadhash={vb:raw bbuserinfo.securitytoken}"; } else { } } //--> </script> </vb:literal> I changed the link for "Mark All Forums Read" to: Code:
<a href="javascript:markAsRead();"><b><font color=red>{vb:rawphrase mark_forums_read}</font></b></a> I end up getting the following error in my browser when trying to follow the link: Quote:
I noticed when the page changes, the URL shows up as: http://www.mysite.com/forumdisplay.php?{vb:raw session.sessionurl}do=markread&markreadhash={vb:ra w bbuserinfo.securitytoken} It looks like the hash and security tokens are not being passed in the Java Script as they were in vB3. I was able to use the following in vB3.8.5 and it works fine, but it isn't working in vB4.x: Code:
<script> <!-- function markAsRead() { var markRead= confirm("Do you really want to mark all forums as read?"); if (markRead== true) { window.location="forumdisplay.php?$session[sessionurl]do=markread&markreadhash=$bbuserinfo[securitytoken]"; } else { } } //--> </script> Code:
<a href="javascript:markAsRead();">$vbphrase[mark_forums_read]</a> Any help would be greatly appreciated! . |
#2
|
|||
|
|||
* Bump *
|
#3
|
||||
|
||||
Try adding the javascript to the headinclude or header template.
|
#4
|
|||
|
|||
The problem is you wrapped the javascript around <vb: literal> tags, which you should do, but that means none of the {vb: raw } tags are being parsed in the script.
Maybe try passing this data through the function? Code:
<a href="javascript:markAsRead({vb:raw session.sessionurl},{vb:raw bbuserinfo.securitytoken );">{vb:rawphrase mark_forums_read}</a> Code:
<vb:literal> <script> <!-- function markAsRead(session, markreadhash) { var markRead= confirm("Do you really want to mark all forums as read?"); if (markRead== true) { window.location="forumdisplay.php?" + session + "do=markread&markreadhash=" + markreadhash; } else { } } //--> </script> </vb:literal> |
#5
|
|||
|
|||
Tried both, no change.
Quote:
I think we are getting closer as it makes sense that the vb:literal tags are causing the noparse. |
#6
|
|||
|
|||
What's the syntax error? I see already that I missed a ")"
so, Code:
<a href="javascript:markAsRead({vb:raw session.sessionurl},{vb:raw bbuserinfo.securitytoken});">{vb:rawphrase mark_forums_read}</a> |
#7
|
|||
|
|||
Quote:
It doesn't tell me what the Syntax Error is. When I hover over the link, it shows: javascript:markAsRead(,1279577127-xxxxxxxxxxxxxxxxxxx) It appears there might be a hash missing. Also, when I click on the Mark All Read button, I don't get the confirmation popup either. |
#8
|
|||
|
|||
Try:
Code:
<a href="javascript:markAsRead('{vb:raw session.sessionurl}','{vb:raw bbuserinfo.securitytoken}');">{vb:rawphrase mark_forums_read}</a> |
#9
|
|||
|
|||
Quote:
That appears to have done the trick! THANK YOU for your help!!! :up::up::up::up::up::up::up: |
#10
|
||||
|
||||
Where did you end up putting the js code?
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|