The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Javascript Inject Images in Post

3 posters

Go down

Solved Javascript Inject Images in Post

Post by Dr.Intern February 3rd 2016, 5:56 am

Technical Details


Forum version : #Invision
Position : Founder
Concerned browser(s) : Mozilla Firefox, Google Chrome
Who the problem concerns : All members
Forum link : chaoticbackup.forumotion.com

Description of problem

I wrote a script that would replace
Code:
<div class='card'>card name<div>
with an image of the corresponding card. Got it to work in jsfiddle.
https://jsfiddle.net/epksyL69/5/

But when I tried in on the forum, nothing happened. I ticked the enable on all pages under javascript management. I don't get any errors in the console related to this script. It just isn't doing anything.

Details on this post


Last edited by Dr.Intern on February 3rd 2016, 11:49 pm; edited 1 time in total
avatar
Dr.Intern
Forumember

Posts : 77
Reputation : 3
Language : English

Back to top Go down

Solved Re: Javascript Inject Images in Post

Post by Ange Tuteur February 3rd 2016, 4:56 pm

Hi @Dr.Intern,

The problem with your script is that it's firing BEFORE the document is ready, so when
Code:
x
gets the specified elements by classname it'll return null, because the document has not yet finished loading ; the elements don't yet exist. Note that all scripts in the AP execute in the HEAD section so you should wrap your code with the following :
Code:
$(function() {

});

The above is shorthand for :
Code:
jQuery(document).ready(function() {

});
This should give a brief explanation : http://www.w3schools.com/jquery/jquery_syntax.asp

You can also use this if you want to stick with native.
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Javascript Inject Images in Post

Post by Ape February 11th 2016, 5:39 pm

Hello @Dr.Intern Is this now Solved ?


Javascript Inject Images in Post Left1212Javascript Inject Images in Post Center11Javascript Inject Images in Post Right112
Javascript Inject Images in Post Ape_b110
Javascript Inject Images in Post Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19176
Reputation : 1996
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Back to top Go down

Solved Re: Javascript Inject Images in Post

Post by Dr.Intern February 11th 2016, 6:00 pm

Yes it is. I had marked solved. Thought that would be enough.

For future reference, should I also respond solved? Thanks.
avatar
Dr.Intern
Forumember

Posts : 77
Reputation : 3
Language : English

Back to top Go down

Solved Re: Javascript Inject Images in Post

Post by Ape February 11th 2016, 6:06 pm

we just like to make sure as there was no reply after the thank post

it would be really nice if you could reply to the Solved post then we would not see it fit to ask LOL

You would not believe it when i say we lock solved icons and some one comes running to us in PM saying Oi you closed my post and it was not solved.

We say why mark it as solved and the reply to that is i must have hit it and not see i have done it

Anyway Thank you .......

Topic solved and archived


Javascript Inject Images in Post Left1212Javascript Inject Images in Post Center11Javascript Inject Images in Post Right112
Javascript Inject Images in Post Ape_b110
Javascript Inject Images in Post Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19176
Reputation : 1996
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum