Welcome to TalkGraphics.com
Results 1 to 10 of 19

Hybrid View

  1. #1

    Default How to know if javascript is executing?

    There are several references on this forum to modifying a page's behavior by placing html of the following form in the body of a page:
    <script type="text/javascript">xr_v1(document.getElementById('message ').parentNode.parentNode)</script>
    Although I've following the "instructions" for using it, I have seen no evidence that it actually works or is even executing ... which leads me to these questions:

    Is there a statement I can add to that block that would display a message or change a color ... or something?
    xr_v1 appears to be a function. Where might I find it documented?
    When such a script is in the body html, when is it executed?

    As you can tell, I'm not versed in javascript. And it's tough to get even a toehold when viewing resources like W3School. But I'm trying to learn.

    Thanks in advance for any assistance.

  2. #2
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,926

    Default Re: How to know if javascript is executing?

    I normally follow siran or Acorn when it comes to JS Contours, I just dabble (badly).

    However copy the following text, paste it into Notepad, save it as test.html & run it in a browser.

    <html>
    <body>

    <p id="p1">What's your name?</p>
    <button type="button" onclick="myFunction()">Answer</button>
    <p><p/>
    <button type="button" onclick="myFunction2()">Reset</button>

    <script>
    function myFunction() {
    document.getElementById("p1").innerHTML = "Contours";
    document.getElementById("p1").style.color = "blue";
    }

    function myFunction2() {
    document.getElementById("p1").innerHTML = "What's your name?";
    document.getElementById("p1").style.color = "red";
    }
    </script>

    </body>
    </html>
    Getting that to work in Xara isn't within my knowledge.
    Egg

    Minis Forum UM780XTX AMD Ryzen7 7840HS with AMD Radeon 780M Graphics + 32 GB Ram + MSI Optix Mag321 Curv monitor
    + 1Tb SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  3. #3

    Default Re: How to know if javascript is executing?

    @Egg: Thanks for that sequence. It's easy to follow what it does when opened in a browser. It's certainly a good start.

    As a test, I named one of the page's text fields "text" and made a crude attempt at grafting one statement into the snippet in the page body ... without any result.
    <script type="text/javascript">xr_v1(document.getElementById('message ').parentNode.parentNode);document.getElementById( "text").style.color = "red"</script>
    If it's even possible to do this, maybe someone can correct my syntax error(s).

    I appreciate your help.

  4. #4
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,926

    Default Re: How to know if javascript is executing?

    Don't know how you attach the code to Xara Buttons but this works with html generated buttons.
    Attached Files Attached Files
    Egg

    Minis Forum UM780XTX AMD Ryzen7 7840HS with AMD Radeon 780M Graphics + 32 GB Ram + MSI Optix Mag321 Curv monitor
    + 1Tb SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  5. #5

    Default Re: How to know if javascript is executing?

    Yes, it does work as you've described. But when I attempted to adapt a single statement into a super-simple test case:
    <script>document.getElementById("text").style.colo r = "red"</script>
    ... nothing changed. I suspect I'm not in the right ballpark with the syntax.

    Thanks for posting the example. I'll continue to look for other examples of "body html" to get a handle on uses.

  6. #6
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,926

    Default Re: How to know if javascript is executing?

    [QUOTE]<script>document.getElementById("text").style.co lo r = "red"</script>[/QUOTE

    Try

    document.getElementById("text").style.color = "red";

    thats without the gap between the o and r in color and the semicolon on the end.
    Egg

    Minis Forum UM780XTX AMD Ryzen7 7840HS with AMD Radeon 780M Graphics + 32 GB Ram + MSI Optix Mag321 Curv monitor
    + 1Tb SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  7. #7
    Join Date
    Feb 2001
    Location
    Surrey, BC, Canada
    Posts
    2,379

    Default Re: How to know if javascript is executing?

    Seems to me the original insert
    that you have a space in 'colo r' maybe not picking that script up due to the space..
    Jim
    Intel i7-2600 processor 3.4GH, Windows 10 64Bit, 12GB Memory, Geforce 960 2Gb graphics card

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •