/    Sign up×
Community /Pin to ProfileBookmark

readonly on form textarea

Hi All,

I’m wondering if it’s possible to make a textarea readonly based on the URL or domain it’s coming from? I’m sure it’s possble, but I can’t find anything on how it’s done.

Regards,

Daz

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@FangJul 23.2008 — URL or domain it's coming from[/QUOTE]What coming from where?
Copy linkTweet thisAlerts:
@toicontienJul 23.2008 — Just test the document.referrer property to detect a domain:
var referrer = document.referrer;

if (referrer.indexOf('www.google.com') > -1) {
myTextArea.readonly = true;
}
Copy linkTweet thisAlerts:
@slaughtersJul 23.2008 — But isn't document.referrer inconsistent ?

Works if you clicked on a link to get to the page, but not if someone just typed in the URL ?

P.S.

If the original poster is referring to current domain then use window.location.hostname
Copy linkTweet thisAlerts:
@irishfighterauthorJul 24.2008 — Thanks for the code, toicontien. Where do I define myTextArea? Is it an id, class...?
Copy linkTweet thisAlerts:
@toicontienJul 24.2008 — [B]myTextArea[/B] is just a dummy variable representing a reference to a <textarea>. How you actually reference a textarea depends on your HTML. Can you post the HTML you are using?
×

Success!

Help @irishfighter spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...