I have a small DropDownList with 3 options .
Problem is when I select , let's say , 2nd option .
No probs , a new page is opened .
If I click on option 1 or 3 , no probs .
However , if I click on 2nd option again , instead of clicking on 1 or 2 , no new page is opened .
Is there a way to correct this , so that clicking on whatever always opens a new window .
Thanks...Vern
SORRY I COULDN'T GET THE "CODE" OR "HTML" TO WORK .
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>myFavs-HtmlProbs.html</title>
<meta name="Generator" content="PureBasic">
<meta name="Description" content="Your description here...">
<meta name="Description" content="...Created by myFavs % PureBasic...">
<style type="text/css">
</style>
</head>
<body text="#000000" style="background-color:#A69E80; text-align:center;">
<br> <br> <br>
<!--dd <div style=-->
<table width="100%" border="0" style="text-align:center" cellspacing="0" cellpadding="0">
<tr style="text-align:center">
<!-- EXAMPLE: <MenuName="aaMost-Used"> --> <!-- rgb(250,240,255) -->
<select style="width:200px; font:14px Arial Black; color:rgb(0,0,0); background-color:rgb(231,169,126);" name="menu" onchange="window.open(this.value)">
<option selected="0" value="">aaMost-Used</option>
<option value="http://alternativeto.net/">AlternativeToSoftwares</option>
<option value="https://www.biblegateway.com/reading-plans/chronological/today?version=NLT">One Year Chronological Bible NLT</option>
<option value="http://www.portablefreeware.com/">portablefreeware.com/</option>
</select></td></tr></table><br></body></html>
Just add this attribute to your select tag
onfocus="this.selectedIndex=0;"
It will change the option to the default option each time after you select one, in your case
aaMost-Used and hence you can then select your required next option again.
When you click on an option more than once, it does not open the page because the option is already selected, and no change occurs. Therefore, onchange isn't fired.
You can actually open a link twice by opening that link, opening another (deselects first) and then clicking on the first link again.
But here's the fix.
Change onchange="window.open(this.value)" to onclick="window.open(this.value)" (onchange to onclick).
That way, the link will be opened whenever an option is clicked, rather than when it changes.
JSFiddle: https://jsfiddle.net/SanPilot/mqqh5u73/1/
Related
<div id="xe-editor-container-1" class="input_area xpress_xeditor_editing_area_container" style="height: 400px;">
<iframe id="editor_iframe_1" allowtransparency="true" frameborder="0" src="http://my_URL.or.kr/xe/modules/editor/styles/default/editor.html" scrolling="yes" style="width: 100%; height: 400px; display: block;">
<html xmlns="http://www.w3.org/1999/xhtml>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="editor.css">
<title>XpressEngine</title>
</head>
<body class="xe_content editable"></body>
</html>
</iframe>
<textarea id="xpress-editor-1" rows="8" cols="42" style="display: none; width: 100%;"></textarea>
<textarea rows="8" cols="42" class="input_syntax " style="display:none"></textarea>
</div>
I want to copy two tables, ListObjects ("Tbl1") on Sheet1, ListObjects ("Tbl2") on Sheet2, and upload them as a single post on the web.
The range of the table can be changed every time.
Logging in to the web, navigating to the bulletin board, pressing the write button and typing the title succeeded.
But I have failed to upload the post.
Perhaps you can not find the bulletin board object.
Code I created by searching the web.
The HTML above is the board's HTML code.
With ie
.navigate "http://my_URL/offering"
ieBusy ie 'Procedure fetched as search (check the ready status)
.Document.getElementsByClassName("ico_16px write")(0).Click
ieBusy ie
Dim oTitle As Object, Ocontents As Object
Set oTitle = .Document.getElementsByname("title")(0) 'Sometimes fail(sometimes Nothing)
Set oContents = .Document.getElementsByClassName("xe_content editable")(0) 'evry time fail(=Nothing)
oTitle.Value = "my Title"
oContents.Value = ????
.Document.forms(0).submit 'I could not confirm it because it did not work anymore.
End With
Sub ieBusy(ie As Object)
Do While ie.Busy Or ie.readyState < 4
DoEvents
Loop
End Sub
title HTML
board HTML
1) Use an additional timed loop to set oTitle as per https://stackoverflow.com/a/55334183/6241235
2) Your oContents variable is selecting for an element which is inside an iframe I think. I would expect you to instead be targeting a textarea element. There are two that come after the iframe. The first has id xpress-editor-1
I am trying to select a value from a dropdown in a web page using Seleinum with VBA binding, but I am unable to do it.
This is the code I tried bot.FindElementById("holder-samples-date-type-inputEl").SendKeys "XX"
I am not getting any error the code runs it click the dropdown button and the list is shown but no value is selected and the dropdown does not change.
I have the same project with VBA and IE (DOM elements) and this code works fine in Internet explorer IE.document.getElementById("holder-samples-date-type-inputEl").Value = "XX"
The interesting part of this dropdown is after clicking the dropdown icon i am unable to inspect the list (like do a right click on the list) and if i click anywhere else in the web page or change the window the dropdown list get closed (like it retracts) note: this is not a mouseover drop down. Also, when the list is open there seems to be additional code added (I have pasted a snippet of the code)
Below is the HTML from the web page.
<div id="holder-samples-date-type-triggerWrap" data-ref="triggerWrap" class="x-form-trigger-wrap x-form-trigger-wrap-default x-form-trigger-wrap-invalid">
<div id="holder-samples-date-type-inputWrap" data-ref="inputWrap" class="x-form-text-wrap x-form-text-wrap-default x-form-text-wrap-invalid"><input id="holder-samples-date-type-inputEl" data-ref="inputEl" type="text" role="combobox" aria-label="Chargebacks: Date Type" aria-readonly="false" aria-required="true" aria-haspopup="true" aria-expanded="false" aria-autocomplete="list" size="1" name="P_samples_Date_Type" readonly="readonly" class="x-form-field x-form-required-field x-form-text x-form-text-default x-form-invalid-field x-form-invalid-field-default" autocomplete="off" aria-labelledby="holder-samples-date-type-labelEl" aria-owns="boundlist-1206" componentid="holder-samples-date-type" data-errorqtip="<ul class="x-list-plain"><div>Date Type</div><li>This field is required</li></ul>" aria-invalid="true"></div>
<div id="holder-samples-date-type-trigger-picker"
aria-label="Trigger" class="x-form-trigger x-form-trigger-default x-form-arrow-trigger x-form-arrow-trigger-default "><img class="combo-trigger-placeholder" src="https://www.sample.net/clr/images/16x16_transparent.png" title="combobox trigger" alt="combobox trigger"></div>
</div>
Below is the image
Since I am unable to do a right click on the dropdown option. I did a 'Find" option in the developer window and below is the webpage code for the dropdown item and it is inside a iframe
<div id="boundlist-1206-listWrap" data-ref="listWrap" role="presentation" class="x-boundlist-list-ct x-unselectable" style="overflow: auto; height: auto;">
<ul id="boundlist-1206-listEl" data-ref="listEl" class="x-list-plain">
<div data-qtip="" class="x-boundlist-item x-boundlist-item-over" tabindex="-1" data-recordindex="0" data-recordid="31" data-boundview="boundlist-1206" id="ext-932" role="option" aria-selected="false">Received Date</div>
<div data-qtip="" class="x-boundlist-item" tabindex="-1" data-recordindex="1" data-recordid="32" data-boundview="boundlist-1206" id="ext-933" role="option" aria-selected="false">Status Date</div>
<div data-qtip="" class="x-boundlist-item" tabindex="-1" data-recordindex="2" data-recordid="33" data-boundview="boundlist-1206" id="ext-934" role="option" aria-selected="false">Due Date</div>
<div data-qtip="" class="x-boundlist-item" tabindex="-1" data-recordindex="3" data-recordid="34" data-boundview="boundlist-1206" id="ext-935" role="option" aria-selected="false">Disposition Date</div>
</ul>
</div>
Some points that may help:
1) If inside an iframe you will need to switch to the iframe first
bot.SwitchToFrame(identifier)
Identifier can be the element selected by iframe name/id etc.
2) You can try click and hold on the input text box before using your SendKeys
bot.FindElementById("x").ClickAndHold
'sendkeys line here
3) You can try setting the value with javascript
bot.ExecuteScript "document.getElementById('x').value = 'xx';"
I wish to make a macro which can auto login a page and then autofill the search input field and finally web scraping the search result.
I have been struggling for a long time that I can successfully login the page. However, when I click the login button, I cannot further get the input tag for the search field as well as adding the value to that input field. The index of those input tags are absolutely correct.
Below is my vba script, many thanks!
Sub login_and_search()
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.Navigate "http://loginpage.html"
Do While .Busy Or _
.readyState <> 4
DoEvents
Loop
Set inputElement = .document.getELementsByTagName("input")
inputElement.Item(0).Value = "abc" 'username
inputElement.Item(1).Value = "xyz" 'password
inputElement.Item(2).Click
Do While ie.Busy Or _
.readyState <> 4
DoEvents
Loop
Set searchField = .document.getELementsByTagName("input")
searchField.Item(0).Value = "searchitems" 'search field
searchField.Item(1).Click
End With
End Sub
Below are the 2 html files, sorry for the too simplified html files as I roughly make them for testing the vba script only. The first one is the login page and the second one is the page after login.
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form class="" action="search.html" method="post">
<input type="text" name="" value="">
<input type="password" name="" value="">
<input type="submit" name="" value="login">
</form>
</body>
</html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form class="" action="searchResults.html" method="post">
<input type="text" name="" value="">
<input type="submit" name="" value="Search">
</form>
</body>
</html>
There is no error showing when running the macro, I think it is a logic error instead of syntax error.
Once again, thanks all!
I haven't used DW for a while, excuse my beginners question.
I have created a table with 2 rows & 1 column within HTML. I have inserted an image in to the top row and one image in to the bottom row.
With border, cell padding and cell spacing set to 0, I cannot figure out why I see pixel padding/spacing at the bottom of each cell. I have changed the background colour of the cells in the table to red so that its easy to show the padding.
Changing the vertical alignment for the cells does not change the issue.
I haven't created CSS page for this.
From what I recall in my previous experience with DW padding and spacing was quite simple when creating a basic table in HTML, so not sure where I am going wrong.
Any help would be much appreciated on where I am going wrong here.
Link to the resulting output when i preview the code in safari and/or chrome
https://dl.dropboxusercontent.com/u/13258883/DW.png
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>
<body>
<table width="512" border="0" cellpadding="0" cellspacing="0" >
<tbody>
<tr>
<td colspan="2" bgcolor="#F50408"><img src="images/Untitled-10_01.gif" width="512" height="107" alt=""/></td>
</tr>
<tr>
<td colspan="2" bgcolor="#F50408"><img src="images/Untitled-10_02.gif" width="512" height="93" alt=""/></td>
</tr>
</tbody>
</table>
</body>
</html>
found the answer i add the following code in to the head
<style>
img {
display:block;
}
</style>
<div class="vcard" itemscope itemtype="http://schema.org/LocalBusiness">
<strong class="fn org" itemprop="name">Commercial Office Bangalore</strong><br/>
<span class="adr" itemprop="address" itemscope itemtype="httep:schema.org/PostalAddress">
<span class="street-address"itemprop="streetAddress">330, Raheja Arcade, 1/1 Koramangala Industrial Layout</span><br/>
<span class="locality"itemprop="addressLocality">Bangalore</span>
<span itemprop="postalCode"class="postal-code">560095</span><br/>
<span class="region"itemprop="addressRegion">Karnataka</span><br/>
<span class="country-name">India</span><br/>
<span class="tel id"="phone"itemprop="telephone">+91-80-41101360</span><br/>
<span class="geo"itemprop="geo"itemscope itemtype="http://schema.org/GeoCordinates">
<abbr class="latitude" property="latitude">12.936504</abbr>
<abbr class="longitude" property="longitude">77.6321344</abbr>
<meta itemprop="latitude" content="12.936504" />
<meta itemprop="longitude" content="77.6321344" />
</span>
</span>
I want to make lat and logitude invisible for user and visible for Google bot. What shall I do?
If you mean the Microdata (using Schema.org):
Just remove the abbr elements. You are already giving this data in meta elements (which can be used in the body), which is the correct way to provide data that should/can not be visible on the page:
<meta itemprop="latitude" content="12.936504" />
<meta itemprop="longitude" content="77.6321344" />
(Note that you were using property attributes, but they are not allowed in Microdata, only in RDFa.)
(Also note that you use http://schema.org/GeoCordinates but it should be http://schema.org/GeoCoordinates. And httep:schema.org/PostalAddress is also wrong.)
If you mean the Microformat (using hCard):
You could reuse the meta elements used with Microdata:
<meta class="latitude" itemprop="latitude" content="12.936504" />
<meta class="longitude" itemprop="longitude" content="77.6321344" />
But I’m not sure if all Microformat parsers support this.
The abbr elements with lat and lon can be set to display:none, which does exactly what you are asking for, hiding the content from humans, while still serving it up to bots:
abbr{display:none}
/** or **/
.latitude,
.longitude{display:none}
Although I can't honestly see what's wrapping them in your example. Ff the span with class .geo is the parent element, you could make that display:none instead.