Question

I wonder if I could get some direction on this problem. I have a forum with a js function to surround text in a message with bb code, but it only works in Opera. In other browsers, it just doesn't do anything, the highlighted words just become not highlighted any more. The actual parser to convert from bbcode to html works fine, its just this surroundText function which is not working.

Here is the routine:

$('.surroundText').click(function(event) {
    event.preventDefault();
    var before = $(this).data('text'),
        after  = $(this).data('text-after');
    surroundText(before, (after) ? after : '');
});

Ultimately I am going to have to install some debugging software and deal with this, but could someone see anything here which is fixable? For some reason Opera works perfectly and everything else doesn't, for a few minor functions on the platform. This is the biggest one.

Edit: Oh and the buttons have this code:

<a class="bold" href="javascript:void(0);" onclick="surroundText('[b]', '[/b]'); return false;" title="Bold">Bold</a>

This is from a working sample...the code is the same, I was confused. Can anyone see a clear problem?

Était-ce utile?

La solution

Finally, I figured this out, its so simple. The jQuery wasn't loading in the other browsers at all. The issue was pretty simple,

When the JavaScript was loaded, the line looked like this:

.script("http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js").wait()

and the problem was that the http: isn't supposed to be there, therefore jQuery wasn't loaded at all.

So the proper line is:

.script("//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js").wait()
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top