watij safari onclick method - html

I am trying to simulate the click event of an anchor tag using watij on mac. I found the tag
<a name="myLink" href="" onClick=""></a>
My code is
Tag link = spec.jquery("a[name=myLink]").click();
But it does not seem to work. Please help.
Thanks & Regards,
Ankur Agrawal

You might try altering your reference to the link. Ex., referencing it by id or class, as shown here:
Hello
-
Tag link = spec.jquery("a.my_link").click();
Additionally, although I am not familiar with Watij, at this point in the code, are you positive that the <a> element has finished loading? You need to verify that all elements in the DOM have loaded before you simulate actions against them.

Related

HREF link not going to output target

I have an href link set to output to target=‘right’. ‘right’ is an I frame in the parent window.
<a href=‘http://www.example.com/abc.pup?ev=$ev’ target=‘right’>Click</a>
The desired target, ‘right’ is in the parent document. The link is not finding the target. It worked well until I I did some editing.
The target attribute specifies where to open the linked document:
You can see details from this link:
https://www.w3schools.com/tags/att_a_target.asp
The right syntax would be:
Click
SOLVED. When the required link href is written in full as http://www.example.com/rqdpage.php the output will be a new window regardless of the target stated, probably for security reasons. The required target is implemented when the required page is in the same directory as the calling page and is stated as a relative path. Thus
<a href=‘rqdpage.php?ev=$ev’ target=right></a>
worked perfectly. Output in frame “right”. Thanks all.

How to access <a> tag which is present inside <th> in VBA that doesn't have id or classname?

I'm trying to automate the web form where I have <a> tag which is inside <th> tag. When I tried getElementByTagName("a").innerText I'm not getting the desired element/text. But when I wrote getElementByTagName("th").innerText it is showing me the exact text that I'm pointing at. But the issue is I wanted to click on the link which this text i.e <a> tag has. getElementByTagName("th").Click is not working. Can someone please help?
There's no such method as getElementByTagName().
There are: document.getElementsByTagName() and Element.getElementsByTagName(). Both return a live HTMLCollection.
In the latter Element refers to a DOM element. It allows you to search for specific tags in children of that element.
Plese refer to the following MDN documents:
Element.getElementsByTagName()
Document.getElementsByTagName()
Also, it's worth mentioning that, without document.* or anything else, the browser would assume you're trying to call window.getElementByTagName().
NOTE: I'm aware the question is tagged vba instead of javascript, but in this case it doesn't seem to matter.

How do I get simple anchors to work in Chrome?

I am no coder, but know enough HTML to get the job done.
I have simple anchors for in-page linking and they work in every browser but Chrome.
What is the average joe explanation of what I can do to get them to work?
[a title="Important Safety Information" href="#isi"] Important Safety Information [/a]
[a id="ISI" name="ISI"][/a]
Page with anchor link: http://educationexchangehcp.ndei.org/novo/bolus-insulin-type-2-diabetes-education-novo-nordisk.aspx
Click on Important Safety Information on the right.
Please help! Thank you,
Brian
Your anchor is in all caps, but the link is in all lowercase. Change the <a id="ISI" name="ISI"></a> to <a id="ISI" name="isi"></a>. Also, if you're not using the ID tag for anything else, I'd just get rid of it. You don't need it for the anchor link to work.
HTML classes and ID names are case-sensitive. Change your code to [a title="Important Safety Information" href="#ISI"].

double action link

Can I create a link that has another link in html.
For example, I want to call an html form and the target will be the sidebar frame.
At the same time, the board frame will also go back to the previous page.
I don't think you would be able to do this in plain HTML, but you could probably use JavaScript to accomplish what you're after.
as steve mentioned you need a bit of javascript:
<iframe id="frame1"></iframe>
<a href="" onclick="update();return false;" >DoubleActionLink</a>
<script>
function update() {
window.open("http://www.stackoverflow.com");
parent.document.getElementById('frame1').src="http://www.w3c.org";
}
</script>
btw, you said
I want to call an html form
html form means you'll submit something to web server...so you aren't asking for pure html solution. Isn't ?
The w3 specification about links clearly states that this is forbidden ..
12.2.2 Nested links are illegal
Links and anchors defined by the A
element must not be nested; an A
element must not contain any other A
elements.
But you can handle the click event through javascript and do additional actions when clicked..
Use target="_top" and set the href to the URL of a <frameset> document which loads all the frames you want by default.
Better yet, don't use frames. They are more trouble than they are worth.

Nesting HTML- anchor tags

Today I was working on a tab navigation for a webpage. I tried the Sliding Doors approach which worked fine. Then I realized that I must include an option to delete a tab (usually a small X in the right corner of each tab).
I wanted to use a nested anchor, which didn't work because it is not allowed. Then I saw the tab- navigation at Pageflakes, which was actually working (including nested hyperlinks). Why?
Nested links are illegal
They must be doing some really crazy stuff with JavaScript to get it to work (notice how neither the parent nor the nested anchor tags have a name or href attribute - all functionality is done through the class name and JS).
Here is what the html looks like:
<a class="page_tab page_tab">
<div class="page_title" title="Click to rename this page.">Click & Type Page Name</div>
<a class="delete_page" title="Click to delete this page" style="display: block;">X</a>
</a>
Actually, the code I had pasted previously was the generated DOM, after all JS manipulation. If you don't have the Firebug extension for Firefox, you should get it now.
Edit: Deleted the old post, it was no longer useful. Firebug is, so this one is staying :)
I suspect that working or not working nested links might depend if your browser renders page in strict mode (e.g. XHTML DTD, application/xml+html MIMEtype), or in "quirks" mode.
In spite of nested tags are illegal but writing them using JS will work!, try this:
$('<a>', {
href: 'http://google.com',
html: '<a>i am nested anchor </a>I am top Anchor'
}).appendTo($('body'))