1

This might be a really simple issue but I cannot spot the problem.

I have this code:

output += '<li><a href="#"><img src="'+value.thumbnail_url+'" /><h3>'+value.title+'</h3>'+value.body+'</a></li>';

I need to add this code after the href="#"

and replace the url string with this: value.media_url

I've come up with:

output += '<li><a href="#" onclick="window.plugins.childBrowser.showWebPage('+value.media_url+');"><img src="'+value.thumbnail_url+'" /><h3>'+value.title+'</h3>'+value.body+'</a></li>';

but there seems to be a syntax issue with the above as the link is not working.

The broken code is somewhere here: onclick="window.plugins.childBrowser.showWebPage('+value.media_url+');" as the rest works fine.

I could go even further ... here:

('+value.media_url+')

Can anyone see the problem?

2 Answers 2

2

The resulting string is:

window.plugins.childBrowser.showWebPage(my/url/to/file.png)

As you can see, it's missing quotes around the string. Since it's in an attribute, you need this:

... onclick="window.plu.....WebPage(&quot;'+value.media_url+'&quot;)" ...
Sign up to request clarification or add additional context in comments.

2 Comments

Tried it but I get the actual &quot; as a string
If you're looking at the HTML source, it's supposed to be like that. The browser will interpret it as quotes and the script should work fine.
1

replacing onclick="window.plugins.childBrowser.showWebPage('+value.media_url+');" with onclick="window.plugins.childBrowser.showWebPage('"+value.media_url+"');" will fix it

2 Comments

Very strange...I replaced it with this: onclick="window.plugins.childBrowser.showWebPage('"+value.media_url+"');" ... and the page show a ); in the top corner for some reason
It's a sadface at this answer's level of fail.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.