Page 2 of 8 FirstFirst 1234 ... LastLast
Results 11 to 20 of 80

Thread: Turn simple javascript code to a button

  1. #11
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    OK latest update John, I solved the problem on the one forum where the "Add image to post" link was still coming up even though we hid it with the style sheet code, that was a plugin on the forum that I really don't need causing the issue. I did go to the author of the plugin to see if it could be fixed to work with this mod.

    But I'm at a loss on the ajax pop up, I turned all plugins off and it still come up, tried this and that, still can't solve it? I've been reading a lot on the ajax pending thing, is it possible it's a thing with the timing with the image uploader not finishing the upload process before it posts the URL in the forum post?

    Maybe along these lines?

    http://www.ask-coder.com/255372/jque...nishes-loading
    Last edited by JRR; 02-23-2015 at 03:39 PM.

  2. #12
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If that's the cause, it would (well should at least) happen without our changes to the mod.postimage.org image script.

    jQuery does have built in error handling for AJAX, but it's off by default. And I don't think that would pop up something like that. What you have looks like part of the browser. Try other browsers and see if they give the same or similar popup.

    For me to diagnose this issue, I would have to see a page where it's happening. Which if any of your forums that I have access to as a member does this happen on? If none, please give me a guest account on one of them.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #13
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    I have the settings here where you can register as a guest or member and it happens here, go to any thread and give it a try.

    http://thescooterprofessor.proboards.com/

    I considered the browser thing, I use Windows 8.1 and IE11, I'll download FF and see about it, I refuse to put chrome on my computer because of the silly ad ons and crap.

  4. #14
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Update John, tried it on Firefox with no issues at all, very clear, quick and no issues, this is a IE problem.

  5. #15
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Yeah, well I see it in IE. Not a disaster, but not pretty at all. The obvious question or test if you haven't tried it already is - does this happen in IE without our modifications to the mod.postimage.org image script?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #16
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Modifications as in the
    Code:
    return false:
    part we added? Or hiding the link with the sytle sheet code?

  7. #17
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Ok John I'll break it down so you can know exactly what is going on.

    The last button code we used was this :

    Code:
    <button onclick="postimage_upload(0); return false;">Insert Image</button>
    <script type="text/javascript" src="http://mod.postimage.org/website-english-family.js" charset="utf-8"></script>
    We have a style sheet code that hides the image host link and the black dot.

    Code:
    <style type="text/css">
    a[href="javascript:postimage_upload(0);"]{
    	display: none;
    }
    div.message div span, div.message div br {
    	display: none;
    }
    </style>

    With this set up we can add text to the post, then a image or vise versa and when we hit the Post Reply button we are getting the ajax message with IE11 but not on Firefox at all. I waiting on a friend to try it with Chrome because I will not put Chrome on my computer. But even with the ajax message with using IE I can hit the "leave this page" on the message and the post works just fine.


    Now here is the other tests I ran, I removed the style sheet code which made the link show back up and when I used the Insert Image button I had the exact same ajax message as before with the link hidden.

    Next I put the style sheet code back in and removed the small part you added to the button code and used you very first button code:

    Code:
    <button onclick="postimage_upload(0);">Insert Image</button>
    <script type="text/javascript" src="http://mod.postimage.org/website-english-family.js" charset="utf-8"></script>
    With this code I got no ajax message but we are back to the problem we had before if you add text then hit the Insert Image button the text will post just like if you hit the post button?

  8. #18
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Try changing:

    Code:
    <button onclick="postimage_upload(0); return false;">Insert Image</button>
    <script type="text/javascript" src="http://mod.postimage.org/website-english-family.js" charset="utf-8"></script>
    to:

    Code:
    <button id="messageimagebutton">Insert Image</button>
    <script type="text/javascript" src="http://mod.postimage.org/website-english-family.js" charset="utf-8"></script>
    <script type="text/javascript">
    $('#messageimagebutton').click(function(e){
    	postimage_upload(0);
    	e.stopPropagation();
    	e.preventDefault();
    });
    </script>
    If that's still no good, try:

    Code:
    <button id="messageimagebutton">Insert Image</button>
    <script type="text/javascript" src="http://mod.postimage.org/website-english-family.js" charset="utf-8"></script>
    <script type="text/javascript">
    $('#messageimagebutton').click(function(e){
    	postimage_upload(0);
    	e.preventDefault();
    	e.stopPropagation();
    });
    </script>
    If that's no help, try:

    Code:
    <button id="messageimagebutton">Insert Image</button>
    <script type="text/javascript" src="http://mod.postimage.org/website-english-family.js" charset="utf-8"></script>
    <script type="text/javascript">
    $('#messageimagebutton').click(function(e){
    	postimage_upload(0);
    	e.stopPropagation();
    });
    </script>
    Then finally (if that's no good):

    Code:
    <button id="messageimagebutton">Insert Image</button>
    <script type="text/javascript" src="http://mod.postimage.org/website-english-family.js" charset="utf-8"></script>
    <script type="text/javascript">
    $('#messageimagebutton').click(function(e){
    	postimage_upload(0);
    	e.preventDefault();
    });
    </script>
    Make sure to clear the cache and refresh the page before each test.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #19
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Ok John followed your instructions to the letter, Code number 1 and 4 are no better at all, instant ajax message, code number 3 does the same as the code that makes the text post as soon as you click on the Insert Image button, it's totally useless.


    At first I thought code number 2 was a winner because I posted about 4 images with no problems at all? But after four image uploads it started bringing up the ajax message. But it was better than the other 3 codes for sure. Also no issues with this code in Firefox.

    I just confirmed this is causing a error message with a user that is using Vista and IE9 Would it be possible to make a working button using <a class="button"> tags?

    I know Proboards uses the
    <a class="button"> to create buttons like the quote and edit so it doesn't accidentally submit the quick reply form.
    Last edited by JRR; 02-24-2015 at 04:45 AM.

  10. #20
    Join Date
    Oct 2013
    Posts
    169
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Ok John another update, been playing around with everything I can find, read about and get help with, trying so much to learn and understand this stuff, I'm beginning to think IE is a monster but having it work correctly isn't just for me, I have a lot of members who use older and newer versions of IE and it's got to be fixed for all of them, again no issues in Firefox and I'll get a answer about Chrome today but I'm betting no issues at all.

    But I did discover this and it's how to make the original simple button code to work without any issues other than the ajax issue, the code:

    Code:
    <a href="javascript:void(0);" onclick="postimage_upload(0);" class="button">Insert Image</a>
    <script type="text/javascript" src="http://mod.postimage.org/website-english-family.js" charset="utf-8"></script>
    As I mentioned earlier a friend mentioned to me from PB that they use this kind of button to keep things in other areas from say mixing with the Quick Reply area and vise versa so by using the <a> onclick version I was able to remove the return false; out of the code and when you click this button now you do not have the problem we encountered before which is why you added it in the first place.

    I went back and tried everyone of the four codes you posting with the different button and no change.


    I don't know at all if this makes any difference in your thinking just trying to find a way to get this to work and throwing ideas out, no one can tell me why the ajax thing is happening.
    Last edited by JRR; 02-24-2015 at 02:51 PM.

Similar Threads

  1. Please write a simple javascript code for me
    By laperashvili in forum JavaScript
    Replies: 2
    Last Post: 06-18-2012, 03:10 PM
  2. adding rollover button to javascript code
    By Repatilian in forum JavaScript
    Replies: 6
    Last Post: 12-04-2011, 10:28 AM
  3. Help with javascript code to make next and previous button dissapear
    By ajmancilla in forum Looking for such a script or service
    Replies: 1
    Last Post: 02-07-2011, 03:00 PM
  4. Looking for a simple Javascript code for a web board
    By donelian in forum Looking for such a script or service
    Replies: 1
    Last Post: 08-15-2007, 10:24 PM
  5. How to turn a menu into a javascript file?
    By Eternal_Howl in forum JavaScript
    Replies: 4
    Last Post: 07-23-2007, 07:16 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •