Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Basic Webpage Controls with JavaScript / COM - Tutorial


  • Please log in to reply
335 replies to this topic
Joe Glines
  • Members
  • 118 posts
  • Last active: Jan 24 2016 03:08 PM
  • Joined: 23 Dec 2009

I'm trying to grab the value of a variable from a script tag on a page.  Below is an example of the script tag from this page.

<script language="JavaScript">
              var tiPageName;
              tiPageName = "NFC / RFID Overview Tab-EN";
        </script>

I've written this which does loop through the script tags and find the one related to tiPageName but I can't find a way to isolate just this: NFC / RFID Overview Tab-EN.  Is there a way to do this by using the DOM structure of the DOM, or do I need to use Regex to grab it?

pwb:=GetIE()
Script_Tags:=pwb.document.all.tags("script") ;get all script tags on page

while A_Index < Script_Tags.length
If InStr(Script_Tags[A_Index].Outerhtml,"tiPageName")
    MsgBox , % Script_Tags[A_Index].innerTEXT  
 

Automating the mundane 1 script at a time...
https://www.linkedin.com/in/joeglines
The-Automator

Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
Did not use mush time

But as i know it the word 'var' before the variable here var tiPageName; make's it a lokal variable only avalible within that function so i don't know of any other way...

On a side note what is that used for? As the javascript only seems to set a lokal variable! Not returning it or using it in Any other way?
Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

Joe Glines
  • Members
  • 118 posts
  • Last active: Jan 24 2016 03:08 PM
  • Joined: 23 Dec 2009

Thanks Blackholyman!   

 

I work at Texas Instruments and we use tealium and Site Catalyst for our webtracking/conversions.  I'm not into the weeds on how it works, but the tiPageName and tiContentGroup are allow us to view metrics back to a given page.


Automating the mundane 1 script at a time...
https://www.linkedin.com/in/joeglines
The-Automator

Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
Okay :) its still puzzling to me but maybe its used in a closure ( was new to me too )

A closure is a special kind of object that combines two things: a function, and the environment in which that function was created. The environment consists of any local variables that were in-scope at the time that the closure was created. In one case, a closure incorporates both the inner function and the local outer variable that existed when the closure was created.


Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

Joe Glines
  • Members
  • 118 posts
  • Last active: Jan 24 2016 03:08 PM
  • Joined: 23 Dec 2009

Interesting...  Thanks for reviewing and the edification on closure!


Automating the mundane 1 script at a time...
https://www.linkedin.com/in/joeglines
The-Automator

dynshiz
  • Members
  • 1 posts
  • Last active: Nov 11 2015 08:28 AM
  • Joined: 10 Nov 2015

Hi there. I need to perform a doubleclick on a web element, is this somehow possible?

 

A simple .Click() does not work in this case...

 

Any suggestions?