Search code examples
javascriptjquerybookmarklet

Need to create Javascript function as bookmark which can be used to validate UI rules on any page opened


I need to create a javascript function which will validate all UI checklist items I have for webpage I'm creating. So what I'm expecting is, all my team members should be able to validate their UI by just clicking on a bookmark in their chrome browser (or any browser)

How to achieve this? I have js function ready but it contains jquery as well.


Solution

  • I'm able to achieve this. I created a bookmarklet

    javascript:(function(){// my code here })();
    

    Now this bookmarklet will run in context of my page, thus I'll have access to all js I have in my page and hence jquery as well.

    What I did is, I call a function which resides in one of the js file in my page say:

    validateUI(){
        validateRule1();
        validateRule2();
        validateRule3();
    }
    

    and in these functions I define my rules