We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4819
    • 2 Posts
    To help my website deal better with small displays (like netbooks) I’ve been using a little javascript to resize the larger images based on the width of the browserwindow (if necessary).
    Now I’m building another side using MODx and would like to do the same. The problem is the editor strips the onload call for the script from the image tag. So I need either a workaround for that or a more native solution for MODx that does the same as the Javascript.


    Thanks,

    Ced
    • Can you not place the onload into the head or bottom of the template? I am not quite certain how you are handling this (and I am no JS guy) but I’d think you could assign a class or id to the image and then have the manipulate the element based on class or id.
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. BlogTwitterLinkedInGitHub
        • 4819
        • 2 Posts
        Afraid that won’t work, it might be a solution if only one or two elements in a fairly small page had to be resized. The page in question is sort of an illustrated tutorial though, containing several dozen pics some or all of which may require resizing.
        If I place the onload in the header or bottom area it’s either executed immediately or after the whole document is loaded or after a predetermined amount of time, neither of those options is really usable in this case. At least I don’t know a method to execute a script for a given element at the time the element is loaded without placing the call in the html line that does the loading (i.e. in the image tag in this case).