Illegal Character; Space is not Allowed - character

I am trying to validate my website and I am unable to solve this. This is the error I get:
**Bad value https://www.facebook.com/sharer/sharer.php?u=https://www.company.com/blog/post/back-to-running/&t=Back to Running for attribute href on element a: Illegal character in query: space is not allowed.**
Where is the space I am supposed to fix? I tried %20, %2F and a bunch of other unicode but everything I tried broke my blog. Also got errors related to XML. Any help would be appreciated.
<a class="tweet" target="_blank" href="https://twitter.com/share?url=https%3A%2F%2Fwww.company.com%2Fblog%2Fpost%2Fback-to-running%2F" title="Tweet This"></a>
<a class="facebook" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://www.snapediting.com/blog/post/back-to-running/&t=Back to Running" title="Share on Facebook"></a>

Try to fix
back-to-running/&t=Back to Running
to
back-to-running/&t=Back%20to%20Running
if not working, use "+":
back-to-running/&t=Back+to+Running

Related

Uncaught SyntaxError: Unexpected token '<' - form tag and onclick

I am a newbie to javascript and am following an old tutorial from 2013 in German.
I wonder if certain commands and codes are now deprecated as I have tried to make this code work in an external javascript file.
function clicked() {
alert("can't you read?");
}
<form>
<input onclick="clicked()" type ="button" value = "don't click"/>
</form>
I get an error message which states:
Uncaught SyntaxError: Unexpected token '<'
I get the same error message when I try this code instead,
<button onclick="clicked()" type="button">"don't click"</button>
I tried to find solutions online, but it appears as if the javascript-verse has evolved to more complicated looking solutions.
Can someone help?
Thanks,
"
I actually figured it out by finding a reference from 2008.
Anything between the form tags and including the form tags goes into the html file.
<form>
<input onclick="clicked()" type ="button" value = "don't click"/>
</form>
The function itself remains on the external javascript file
function clicked() {
alert("can't you read?");
}
The solution looks definitely simpler than all other onsubmit or onclick codes I have seen today. I therefore assume that I may miss some tricks by being overly simplistic.

Get inner most regex match for a href regex catcher

I want to catch href tags with a youtube link inside them.
I have this regex:
"<a.*?href=(.*?youtu.?be.*?)>.*?</a>"
It works but it doesn't stop if the tag is closed.
Meaning if I have:
<a href=www.google.come>google</a> <a href=www.youtube.com>youtube</a>
Desired result:
<a href=www.youtube.com>youtube</a
Actual result:
<a href=www.google.come>google</a> <a href=www.youtube.com>youtube</a>
It catches the whole thing, recognizing Googles <a as the opener and youtubes </a> as the closer.
I want to make my regex a little smarter so it knows how to stop the match when the the Google closer appeared, and start a new match attempt when the Youtube opener appears.
I tried this but it didn't work:
"<a.*?[^>]href=(.*?youtu.?be.*?)>.*?</a>"
And also tried this:
"<a[^>].*?href=(.*?youtu.?be.*?)>.*?</a>"
You can try this pattern :
"<a[^>]*?href=[^>]*?youtu.?be[^>]*?>[^>]*?<\/a>"

Why does the first assert work, but not the second?

I'm using Watir WebDriver with Firefox.
Here are two asserts for the same element. The first works, but not the second:
assert_match(/Please add user to GMT/, #browser.small(:class, "error").text)
assert_match(/Please add user to GMT/, #browser.div(:class, "eight mobile-three columns").small(:class, "error").text)
I need the second assert to work, because there are 8 error messages on the page, which are presented if the user does not populate 8 mandatory fields. All 8 errors have the identical HTML. So, I need to be able to step down from the parent.
Here is the HTML:
<div class="eight mobile-three columns">
<a id="btnAddUserToGMT" class="success radius button expand error" onclick="AddUserToGMT();" data-reveal-id="addToGMT" href="#"> … </a>
<small class="error" style="margin-top:0px;">
Please add user to GMT
</small>
</div>
Here is the error message:
Watir::Exception::UnknownObjectException: unable to locate element, using {:class=>"error", :tag_name=>"small"}
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/elements/element.rb:490:in `assert_exists'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/elements/element.rb:85:in `text'
C:/Documents and Settings/Asserts_01.rb:22:in `testBasic'
The complaint for the second assert is:
unable to locate element, using {:class=>"error", :tag_name=>"small"}
And yet that same using was OK for the first assert.
Problem solved.
After discussion with the developer, it appears that by some unusual manipulation of automatically generated HTML, the text of the error message appears at its correct location on the page. But the assertion must be based on a different tag, which is specified at some completely different position on the page.
For example, I was trying to assert on this code at the correct position:
<small class="error" style="margin-top:0px;">
Gender is required
</small
Even unique xPath generated by FirePath failed to find this.
What I should have asserted on was a HIDDEN tag on a completely different part of the page.
<input id="errorMsgGenderID" name="errorMsgGenderID" type="hidden" value="Gender is required" />
There were several such tags for each mandatory field that was not populated, all bunched together on the same line. They were all "input" tags, which puzzled me.

Need help to click Watir Web driver button

I have the HTML as
<li>
<div data-track="discovered_spots" data-filter="discovered_spots" class="button filter-button">
<span class="icon-compass"></span>
Discoveries (2)
</div>
</li>
I am trying to click the button link
#browser.div(:class =>'button filter-button').span(:text => ' Discoveries (2) ').click
Just not working or producing any errors.
I have also tried using the xpath
##browser.div(:xapth => "//div[#data-track='discovered_spots']").click
##browser.div(:text => "Discoveries").click
but that produce errors.
I have also viewed and tried the code present in other questions chains but none worked any help will be very useful.
Try:
#browser.div(:text, /Discoveries/).click
Regex for the attribute should hit the text. Not specifying \d anchor will cast a wider net in case that value of 2 fluctuates by only looking for the match of Discoveries in text and ignoring the number and parentheses.

jquery .html() returning null in ie7

On click li element i am getting the current element value and appending it into another div dynamically.Its working fine in all browsers.But returning null in IE7.I don`t the reason that why its happening?Please can any one give me a solution for this..Part of the code only i pasted here.
Sample code:
////////////.//This line returning null in IE7./////////////////
$('#pagelink_a #pagelinkli_'+tab_lastid_val).html()
(tab_lastid_val value can be a 1 or 2 or 3.Clixked li element value comes here)
<div class="pagelink">
<div id="pagelink_a">
<ul>
/******** all li element are clickable***********/
<li id="pagelinkli_1"><a>Google</a></li>
<li id="pagelinkli_2"><a>Chrome</a></li>
<li id="pagelinkli_3"><a>Firefox</a></li>
</ul>
</div>
</div?
try this:
$('#pagelink_a').find('li[id=pagelinkli_'+tab_lastid_val']').html();
code is not tested but i think it should work.
Given your html layout, your parent div is .pagelink not #pagelink_a , so replace your following line:
$('#pagelink_a #pagelinkli_'+tab_lastid_val).html()
for this one:
$('.pagelink #pagelinkli_'+tab_lastid_val).html()
Just use
$('#pagelinkli_'+tab_lastid_val).html()
The # tag identifies an ID which only a single element may have. There is no need to have anything preceding it. You also labeled the previous class as id, which is wrong. I don't know how your other browsers managed to get anything.
Although bit off topic, it may be better to actually drop IE7 support entirely. Due to small user base and decreasing popularity, it may be costing you more money by support it than to not support it.
Try instead of html() , and try append().
For example
$('#ID').append('Your content');