+ Reply to Thread
Results 1 to 21 of 21

how to click javascript alert button when using IE

  1. #1
    Forum Contributor
    Join Date
    11-12-2010
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    189

    how to click javascript alert button when using IE

    Hi all,

    I am using below code (method from this web) to extract data from the web, the problem I am facing is the popup alert message from the web which stop my procedure to further execute.

    This is the web code of the search button (sorry that I dunno the reason of failure to post the full search button web code on the forum, so I just extract part of it)
    HTML Code: 
    Could anyone tell me how to solve the problem of frozen vba procedure after the popup of the alert? Many thanks!!

    Please Login or Register  to view this content.
    English is not my first language

  2. #2
    Forum Contributor
    Join Date
    11-12-2010
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: how to click javascript alert button when using IE

    to add more background information,
    1.) I cannot click any button on VBE after the red line, but I can still control/operate other window objects such as outlook and chrome.
    2.) If I tried the website which is from the original example from this web https://social.technet.microsoft.com...tprocurrentver, everything works fine. So I dunno if my problem is due to the search button generated by Javascript .

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: how to click javascript alert button when using IE

    It freezes because you have inserted an invalid date as you can see the error on the site. Change the year in to "2016" and will take you to next page.

  4. #4
    Forum Contributor
    Join Date
    11-12-2010
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: how to click javascript alert button when using IE

    Quote Originally Posted by AB33 View Post
    It freezes because you have inserted an invalid date as you can see the error on the site. Change the year in to "2016" and will take you to next page.
    Thanks, AB33.
    This is an intended attempt to insert a invalid date because users always got a chance to insert the date like this case.
    When this happens, they need to manually click ok in the popup alert.
    So, I am seeking help on this forum to see if experts can any idea to solve this issue.

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: how to click javascript alert button when using IE

    What information is it that you're trying to extract from the next page?

  6. #6
    Forum Contributor
    Join Date
    11-12-2010
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    189
    Quote Originally Posted by Kyle123 View Post
    What information is it that you're trying to extract from the next page?
    The data I would like to extract is a table, but what is the relationship between your question and my problem?

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: how to click javascript alert button when using IE

    Because this is an example of an xy problem, you don't need to use IE at all to get the information. The question should be, how do I get the info rather than how do I deal with the box in IE.

    The reason I asked the question was that if you didn't need to extract the data and just needed to open the page then the method becomes more relevant

  8. #8
    Forum Contributor
    Join Date
    11-12-2010
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: how to click javascript alert button when using IE

    Quote Originally Posted by Kyle123 View Post
    Because this is an example of an xy problem, you don't need to use IE at all to get the information. The question should be, how do I get the info rather than how do I deal with the box in IE.

    The reason I asked the question was that if you didn't need to extract the data and just needed to open the page then the method becomes more relevant
    ok, I see. Because there is a captcha (session-token) which changes every time when I send the web request to the server by using xmlhttp request method, and I cannot solve the issue of changing captcha. So, I change to use IE automation to extract the data.
    Please Login or Register  to view this content.
    This is the captcha which changes every time I send the web request.
    Until now, I am able to manage the data extraction. However, when there is a javascript popup alert (as described above), I could do nothing. That's why I am posting a thread on the forum. If anyone of you has idea to workaround the issue, pls let me know. Thanks again.

  9. #9
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: how to click javascript alert button when using IE

    Where do you see a captcha on that page? I don't

  10. #10
    Forum Contributor
    Join Date
    11-12-2010
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: how to click javascript alert button when using IE

    Quote Originally Posted by Kyle123 View Post
    Where do you see a captcha on that page? I don't
    after entered
    HTML Code: 
    , view source code and search by "sessionToken", this is one of the inputs required in order to successfully load next page. The value of sessionToken changes every time when I open a new browser

  11. #11
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: how to click javascript alert button when using IE

    That's not a captcha - a captcha is designed to stop bots, that's just a session token. This worked for me:
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    11-12-2010
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: how to click javascript alert button when using IE

    Quote Originally Posted by Kyle123 View Post
    That's not a captcha - a captcha is designed to stop bots, that's just a session token. This worked for me:
    Please Login or Register  to view this content.
    Amazing!!Kyle123, you are deserved to add reputation, thanks again!!
    BTW, just for curiosity, if back to my original problem (vba procedure was frozen after running the red line), do you have any idea?
    Use the same method, some website could apply while others do not.

  13. #13
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: how to click javascript alert button when using IE

    I haven't run your code, but were I to guess, the alert box puts IE into a busy state. This isn't resolved until the box is closed, your loop keeps running whilst IE is busy, so you never get out of the sleep loop

  14. #14
    Forum Contributor
    Join Date
    11-12-2010
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: how to click javascript alert button when using IE

    is it another field of vba? I wanna learn how to control other window objects (in this case the popup alert)?

  15. #15
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: how to click javascript alert button when using IE

    You need to look into window handling with sending messages, you use the Windows api. It's an incredibly unsatisfying and painful learning experience - it's very easy to crash excel when faffing with these things

  16. #16
    Forum Contributor
    Join Date
    11-12-2010
    Location
    HK
    MS-Off Ver
    Excel 2010
    Posts
    189
    Quote Originally Posted by Kyle123 View Post
    You need to look into window handling with sending messages, you use the Windows api. It's an incredibly unsatisfying and painful learning experience - it's very easy to crash excel when faffing with these things
    Hi Kyle123, regarding your solution, there are 2 points that I don't quit understand, could you kindly explain a little bit more?
    1.) what's the purpose of this portion of code
    .Open "GET", url, False
    .send
    doc.body.innerhtml = .responsetext
    Is this used to extract the sessiontoken?

    2.) why there is no need to have .Setheaderrequest in http get part?

    Thank you so much

  17. #17
    Registered User
    Join Date
    06-07-2016
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    25

    Re: how to click javascript alert button when using IE

    hi lubbamkt, may I ask, what will be the result of this code? is that returning the token or it will return the table?

    I am sorry, I am a beginner in vba excel and also interested on extracting data from the same webpage as yours

  18. #18
    Registered User
    Join Date
    06-07-2016
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    25

    Re: how to click javascript alert button when using IE

    Hi, Kyle, I have recently read your reply on "how to click javascript alert button when using IE"

    Link: http://www.excelforum.com/excel-prog...-using-ie.html


    I understand you are using get and post to retrieve the response and copy it into the responsetext and loop up the corresponding token and table.

    I have tried your method, but however I found out that the data retrieved are not complete

    In the

    For Each rw In doc.getelementsbyTagname("table")

    Debug.Print rw.innertext

    Next rw

    After print out the table is complete, only those shareholding with 0% are printed out.

    I have tried to print the responsetext before filtering tagname "table" and it also shows that the table is not complete

    May I ask whats the problem?

    Thank you

  19. #19
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: how to click javascript alert button when using IE

    Welcome the forum, Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

  20. #20
    Registered User
    Join Date
    06-07-2016
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    25

    Re: how to click javascript alert button when using IE

    Sure, I will post another thread

  21. #21
    Registered User
    Join Date
    06-07-2016
    Location
    Hong Kong
    MS-Off Ver
    2010
    Posts
    25

    Re: how to click javascript alert button when using IE

    please teach me in my new thread, thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Running the code in an option button from a seperate normal button click
    By camikhazi in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 01-22-2016, 10:54 AM
  2. Button Click on Spreadsheet commanded by Button Click on Userform
    By Quilie19 in forum Excel Programming / VBA / Macros
    Replies: 33
    Last Post: 04-07-2015, 11:35 PM
  3. [SOLVED] click on a color button and after button click it will color entire row of cell you click
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-11-2014, 06:06 PM
  4. [SOLVED] Help click on link javascript webpage
    By rickmdz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-06-2012, 11:59 PM
  5. Call button click event from a button on anther sheet
    By ajaykgarg in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-25-2010, 09:27 AM
  6. Radio button alert
    By a94andwi in forum Excel General
    Replies: 2
    Last Post: 11-25-2008, 10:13 AM
  7. [SOLVED] [SOLVED] Create floating button based on button click in menu
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-12-2005, 02:05 PM

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1