November 22, 2019 at 2:09 pm #299462victorugobParticipant
Hi everyone, I’ve been trying to adjust the margin of my .content-area when the div of the sponsored doesnt show or load. I’ve done the trick later with a simple script like that:
jquery(‘.content-area’).css(‘margin’, ‘0 15%’);
But recently i’ve made a few changes to the menu and brought up some code from another site, now theres no script that works on adjusting the content margin. Could you guys help me out on that?November 25, 2019 at 4:38 am #299507JeroenRParticipant
Well we can’t really guess what changes you made, so maybe you can show the code in a demo (codepen for example). One piece of code with the sponsored HTML and one without?November 25, 2019 at 6:07 am #299519victorugobParticipant
Hi JeroenR, thanks for taking your time to reply. I’ll try to explain it better.
The old one has a different structure. but it has he same concept: side and bottom ads.
When the side ad image wont load, it was suppose to adjust margin to 0 15% to stick at the center, without this, it would look like the content is stick to the left.
It was something like this
Im still using old site structure, the new one doesnt have the .content-area nor the IfBanner function as showed in the codepen i sent here, it adjust itself
Here is the site im using as referece: bit.ly/2DcxTaL
And here is the one i’m having issues: bit.ly/2OhvqCd
Am I missing something in the javscript? Sorry for the long reply thoughNovember 25, 2019 at 7:21 am #299527AtelierbramParticipant
On the page of the last link there are far too many errors. First try validator.w3.org to fix some of the unclosed tags etc. , then fix the asset paths of the missing assets (look at the console in developer tools)November 26, 2019 at 2:35 am #299607JeroenRParticipant
Yes, unfortunately the codepen you provided isn’t really helpful. Nevertheless, if you want to check the presence of some elements after the loading script of the sponsored elements, then you will need to have an event which tells you that the loading script of that sponsoring is done.
By default you can assume the HTML of the sponsored block is not in there, do something with that situation.
Then, on the event triggered by the sponsoring, you can have a function which checks the HTML and do something with that situation.
Question is, is there a load event or ready event or something like that in the script that load the content of your sponsors?
If not, maybe you can use something like mutation observer for detecting the changes. Use it on the element where the content of the sponsor gets appended to.