![]() |
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> 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> Code:
<a href="javascript:markAsRead();">$vbphrase[mark_forums_read]</a> Any help would be greatly appreciated! . |
* Bump *
|
Try adding the javascript to the headinclude or header template.
|
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> |
Quote:
Quote:
I think we are getting closer as it makes sense that the vb:literal tags are causing the noparse. |
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> |
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. |
Try:
Code:
<a href="javascript:markAsRead('{vb:raw session.sessionurl}','{vb:raw bbuserinfo.securitytoken}');">{vb:rawphrase mark_forums_read}</a> |
Quote:
That appears to have done the trick! THANK YOU for your help!!! :up::up::up::up::up::up::up::):):):):) |
Where did you end up putting the js code?
|
Quote:
|
No problem. :)
And Boofo is right, javascript should go in the headinclude template. |
Quote:
One other problem I am having with this script. Occasionally in certain browsers, I get a "Your Submission could not be processed due to an invalid security token" error when trying to Mark All Read. Doesn't happen in IE8, but happens on the browser on my Droid (Safari derivative I believe). Any thoughts? |
This occurred with the new version? Or has been happening?
|
Quote:
|
Is there anyway to check if the browser handles js and use the regular link for those occasions that it doesn't?
|
Quote:
Code:
// Prevent CSRF. See #32785 |
Can you check the URL upon redirect? Is there a hash in the query string?
|
Quote:
|
I'm trying to use this method but when i add this function and hit the save button, it says
Fatal error: Maximum function nesting level of '100' reached, aborting! in /var/www/includes/vb_template.php on line 51 how can i resolve this problem? --------------- Added [DATE]1314536746[/DATE] at [TIME]1314536746[/TIME] --------------- Finally, i can include this function from external file... But now it's not working with vb4.1.5 I've add Code:
<script type="text/javascript" src="markread.js"></script> Code:
function markAsRead(session, markreadhash) Code:
<a href="javascript:markAsRead({vb:raw session.sessionurl},{vb:raw bbuserinfo.securitytoken});">{vb:rawphrase mark_forums_read}</a> |
All times are GMT. The time now is 12:24 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|