Skip to main content

Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #299462
    victorugob
    Participant

    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(‘.className img’).length){
    //atributes
    }
    else {
    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?

    #299507
    JeroenR
    Participant

    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?

    #299519
    victorugob
    Participant

    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 though

    #299527
    Atelierbram
    Participant

    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)

    #299607
    JeroenR
    Participant

    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.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.