Welcome guest, is this your first visit? Create Account now to join.
Results 1 to 6 of 6

This is a discussion on New to Chrome, quick getElementById question within the Plugins Development section, part of the Chrome Plugins category: Hi, I'm new to Chrome, I decided to port a few of my firefox addons to Chrome. Hit a bit ...


  1. #1
    DRZ
    DRZ is offline Junior Member
    Join Date
    Aug 2010
    Posts
    3

    Default New to Chrome, quick getElementById question

    Hi, I'm new to Chrome, I decided to port a few of my firefox addons to Chrome. Hit a bit of a wall and I'm sure I'm being stupid, but can't see the forest for the trees.

    I've got a web page completely loaded, it contains a TEXTAREA called 'edit-body' but my getElementById doesn't seem to work, but in Firefox it does.



    Code:
    var e = document.getElementById('edit-body');
    alert(e);
    Firefox result = [object HTMLTextAreaElement]

    Chrome result = null

    Would anyone like to point out my blatantly obvious error / stupidity.

    Cheers
    Phil
    Last edited by DRZ; 08-26-2010 at 02:59 PM. Reason: formatting

  2. #2
    PAEz's Avatar
    PAEz is offline Moderator
    Join Date
    Aug 2009
    Location
    Australia
    Posts
    656

    Default

    Im a crap coder so I might be missing something but that looks like it should work? I tried it on this page and it got it....
    Code:
    var e = document.getElementById('vB_Editor_QR_textarea');
    alert(e);
    ...is the element in a frame and do you have all frames set in your manifest?
    ...your doing this in the content script right?

    For any further help it would really help if you could give a link to the page your doing this on.

  3. #3
    DRZ
    DRZ is offline Junior Member
    Join Date
    Aug 2010
    Posts
    3

    Default

    I'm crap too, but I'm a stubborn git and refuse to give up.

    In the end I got what I wanted in the Background.html and sent it via a listener to the Content.js via a listener. Pretty easy to do once you know how.

    Code:
        chrome.extension.onRequest.addListener(
              function(request, sender, sendResponse) {
                if (request.greeting == "hello")
                  sendResponse({farewell: gburl});
            else
                  sendResponse({}); // snub them.
          });
    So ........ a 3 day migrain later I unistalled the chrome dev edition and installed the standard 5.0, only to find out you can't modify the ContextMenus in 5.

    I want to cry, any idea when you'll be allowed too?

    Code:
     "permissions": ["contextMenus", "tabs", "http://*/", "https://*/", "http://www.google.com/*"]

  4. #4
    Waha's Avatar
    Waha is offline Senior Member
    Join Date
    Apr 2009
    Location
    Oregon
    Posts
    788

    Default

    Are you sure that element was loaded? Maybe it was added dynamically after your code was called?
    I'd say, try the same code in the console for that page, and if it works, then there's some kind of issue where the element hasn't been made yet
    ~ Projects ~
    Specialized: Carapass Auction Watcher, Kongregate Chat
    Libraries: bliplib
    Tools: manifest syntax highlighting & snippits
    ~ Happy to make extensions for pay too ;D ~
    Portfolio: Search and Share

  5. #5
    DRZ
    DRZ is offline Junior Member
    Join Date
    Aug 2010
    Posts
    3

    Default

    Yeah, it's there... I'm rubbish at this internet lark as I program applications for a living!

    Just found out I won't be able to modify the ContextMenu to Chrome 6 official's released. Anyone know how long that'll be?

  6. #6
    Waha's Avatar
    Waha is offline Senior Member
    Join Date
    Apr 2009
    Location
    Oregon
    Posts
    788

    Default

    No one knows, and it's not guaranteed it'll be out with Chrome 6 stable, that's only if they decide that the system is good enough.
    But really the only time getElementById returns a null is when the element's not there..so.. :/ The only other possibility is that you're using a different DTD which I really doubt.
    ~ Projects ~
    Specialized: Carapass Auction Watcher, Kongregate Chat
    Libraries: bliplib
    Tools: manifest syntax highlighting & snippits
    ~ Happy to make extensions for pay too ;D ~
    Portfolio: Search and Share

Similar Threads

  1. Chrome extension for quick proxy setting
    By W.Z. in forum Chrome Plugins
    Replies: 4
    Last Post: 08-22-2011, 06:28 AM
  2. Google Chrome Question
    By westony in forum Chrome Talk
    Replies: 3
    Last Post: 05-06-2010, 06:51 AM
  3. Google Chrome Question
    By moogle1979 in forum Chrome Talk
    Replies: 2
    Last Post: 04-15-2010, 12:49 PM
  4. Question about Google Chrome??? HELP
    By carrollw in forum Chrome Talk
    Replies: 1
    Last Post: 03-01-2010, 12:58 PM
  5. Chrome Plugins Question
    By Neillithan in forum Chrome Plugins
    Replies: 8
    Last Post: 05-31-2009, 01:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •