Sign in to follow this  
Followers 0
VenusProject2

HREF tag syntax errors

10 posts in this topic

Hi all,

I am trying to understand why when I find auotit code in the forums that has HREF tag of this format, see below, that I get a "syntax error" & yet other don't seem to, am I missing something?

Thanks in advance:

#include <IE.au3>
$oIE = _IECreate("www.google.com")
_IELinkGetCollection($oIE)
Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
For $oLink In $oLinks
    MsgBox(0, "Link Info", $oLink.href)
    If $oLink.href = "<a href='http://www.youtube.com/?tab=w1' class='bbc_url' title='External link' rel='nofollow external'>http://www.youtube.com/?tab=w1"</a> Then ;click on the youtube link
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next

OR

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("PayMeNow", 463, 153, 192, 114)
$btnPayMe = GUICtrlCreateButton("Pay Me Now", 168, 48, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $btnPayMe
            ShellExecute("<a href='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&currency_code=USD&hosted_button_id=<PUTBUTTONIDHERE>' class='bbc_url' title='External link' rel='nofollow external'>https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&currency_code=USD&hosted_button_id=<PUTBUTTONIDHERE>"</a>);

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You have a " in the wrong place:

#include <IE.au3>

$oIE = _IECreate("www.google.com")

_IELinkGetCollection($oIE)

Local $oLinks = _IELinkGetCollection($oIE)

Local $iNumLinks = @extended

MsgBox(0, "Link Info", $iNumLinks & " links found")

For $oLink In $oLinks

    MsgBox(0, "Link Info", $oLink.href)

    If $oLink.href = "<a href='http://www.youtube.com/?tab=w1' class='bbc_url' title='External link' rel='nofollow external'>http://www.youtube.com/?tab=w1</a>" Then ;click on the youtube link

        _IEAction($oLink, "click")

        ExitLoop

    EndIf

Next
Edited by Geir1983

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thx Geir1983 that worked :thumbsup:. The thing that threw me was almost everywhere I found a HREF tag the code was WRONG as in the 2 examples above

Edited by VenusProject2

Share this post


Link to post
Share on other sites

Ok I'm seeing this syntax error more and more, how does everyone not get the syntax error, am I missing something? Please help clear this up for me, is this a version issue? :

This is a code extract from> Best SMS Sender yet!

If $s_Username <> "" Then
        $objEmail.Configuration.Fields.Item("<a href='http://schemas.microsoft.com/cdo/configuration/smtpauthenticate' class='bbc_url' title='External link' rel='nofollow external'>http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"</a>) = 1
        $objEmail.Configuration.Fields.Item("<a href='http://schemas.microsoft.com/cdo/configuration/sendusername' class='bbc_url' title='External link' rel='nofollow external'>http://schemas.microsoft.com/cdo/configuration/sendusername"</a>) = $s_Username
        $objEmail.Configuration.Fields.Item("<a href='http://schemas.microsoft.com/cdo/configuration/sendpassword' class='bbc_url' title='External link' rel='nofollow external'>http://schemas.microsoft.com/cdo/configuration/sendpassword"</a>) = $s_Password
    EndIf

This is just 1 example & above of many I find on the forums here.....

Share this post


Link to post
Share on other sites

where do you get the error? please be more specific

Share this post


Link to post
Share on other sites

same problem again, you need to move the " to after the </a>

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I saw that too but since I'm not familiar with what he was doing, wasn't sure, thy Geir1983, If I may ask (sorry for the stupidity very little HTML skill) but that </a> is the closing thingy for the <a href... and as basicly part of the HTML he was trying to work with right?

I just have some incling that this code would "configure" said control to have its field filled with the variable, much like innertext but I'm not sure, but here to learn first and for most so I ask :)

Edit: and sorry for th unprofessional language

Edited by SorryButImaNewbie

Share this post


Link to post
Share on other sites

Yes, its the end of the html, but the problem here is not related to html, it is passing a variable to the object that is failing.

A string variable is always between two " (or '), when he closes the string and then writes the <a> after it creates a syntax error.

1 person likes this

Share this post


Link to post
Share on other sites

Thanks I wans't 100% sure that my assumption is correct, now I'm :)

Share this post


Link to post
Share on other sites

Yes, its the end of the html, but the problem here is not related to html, it is passing a variable to the object that is failing.

A string variable is always between two " (or '), when he closes the string and then writes the <a> after it creates a syntax error.

 

Thx guys. Sorry for my late reply, the thing is, why are there so many instances of what is discussed as  'legitmate' code posted in the forums with this syntactical error, e.g. in Scite if you past the code/s as I posted it gives a syntax error.  It is the closing </a> that  is outside the "".

Another example

$sTitle = "Test GUI"
GUICreate($sTitle)
$Menu_help = GUICtrlCreateMenu("&Help")
$Menu_Donate = GUICtrlCreateMenuItem("&Donate", $Menu_Help);; you can do the same with a button but the menu item is less obtrusive IMO.
GUISetState()
While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case -3
            Exit
        Case $Menu_Donate
            ShellExecute("<a href='http://dundats.mvps.org/donating.aspx?app=' class='bbc_url' title='External link' rel='nofollow external'>http://dundats.mvps.org/donating.aspx?app="</a> & $sTitle)
            ;;The ?app= query string is only to make it more flexible for me.  If blank then it assumes donation to the website
    EndSwitch
WEnd

& another

$Url = "<a href='http://dundats.mvps.org/autoit' class='bbc_url' title='External link' rel='nofollow external'>http://dundats.mvps.org/autoit"</a>
ShellExecute(@programFilesDir & "\Internet Explorer\iexplore.exe", $Url, "", "", @SW_Minimize)

I'm trying to use the "ShellExecute"

 

This doesn't work even though there is no syntax error, move the " to enclose the last </a> tag, not sure how others got these scripts to work....

$Url = "<a href='http://dundats.mvps.org/autoit' class='bbc_url' title='External link' rel='nofollow external'>http://dundats.mvps.org/autoit</a>"
ShellExecute(@programFilesDir & "\Internet Explorer\iexplore.exe", $Url, "", "", @SW_Minimize)

Any ideas? Are you guys seeing the syntax error in Scite when using "AU3Check"/"SyntaxCheck Prod"?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0