Note that there are some explanatory texts on larger screens.

plurals
  1. POappend a child in javascript in google chrome extension
    text
    copied!<p>I'm writing my first program to make an extension in Google chrome, i just took the "hello world" tutorial as example from <a href="http://code.google.com/chrome/extensions/getstarted.html" rel="nofollow">here</a></p> <p>This is my html file source code :</p> <pre><code>&lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Getting Started Extension's Popup&lt;/title&gt; &lt;style&gt; body { min-width:357px; overflow-x:hidden; } img { margin:5px; border:2px solid black; vertical-align:middle; width:75px; height:75px; } &lt;/style&gt; &lt;!-- JavaScript and HTML must be in separate files for security. --&gt; &lt;script src="popup.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>ad this is my javascript file source code :</p> <pre><code>var req = new XMLHttpRequest(); req.open( "GET", "http://api.flickr.com/services/rest/?" + "method=flickr.photos.search&amp;" + "api_key=90485e931f687a9b9c2a66bf58a3861a&amp;" + "text=hello%20world&amp;" + "safe_search=1&amp;" + // 1 is "safe" "content_type=1&amp;" + // 1 is "photos only" "sort=relevance&amp;" + // another good one is "interestingness-desc" "per_page=20", true); req.onload = showPhotos; req.send(null); function showPhotos() { var photos = req.responseXML.getElementsByTagName("photo"); var element = document.createElement('h1'); element.appendChild(document.createTextNode ('tete '+document.location.href+'hgdfhgd')); for (var i = 0, photo; photo = photos[i]; i++) { var img = document.createElement("image"); img.src = constructImageURL(photo); document.body.appendChild(img); } } // See: http://www.flickr.com/services/api/misc.urls.html function constructImageURL(photo) { return "http://farm" + photo.getAttribute("farm") + ".static.flickr.com/" + photo.getAttribute("server") + "/" + photo.getAttribute("id") + "_" + photo.getAttribute("secret") + "_s.jpg"; } </code></pre> <p>The example is very simple and it works fine, but when add my own javascript instruction, it doesn't display it, the instruction that added is in showPhotos() function and it's :</p> <pre><code> var element = document.createElement('h1'); element.appendChild(document.createTextNode ('tete '+document.location.href+'hgdfhgd')); </code></pre> <p>in the result, i can see the other content but my 'h1' i don't see it. i missed something ? can anyone help me please ?</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload