0

I was wondering if there's a way for scripting websites with c++ instead of or in addition to javascript? DO I put

<script type = "text/c++" src="script.cpp">//code here</script> 

?

3
  • what exactly are you trying todo? You can't just combine two languages like that. Commented Jan 5, 2013 at 20:24
  • 1
    Like how you can program html with javascript by doing <script type = "text/javascript"> can you do the same with c++? Commented Jan 5, 2013 at 20:26
  • No. You can't do this. For one thing, C++ is not a scripting language. Commented Jan 6, 2013 at 6:51

3 Answers 3

3

The only language supported reliably (in script elements) across browsers is JavaScript.

Internet Explorer also supports VBScript. Given a plugin from ActiveState (which I think may be discontinued now) IE also supports PerlScript.

You can embed a program written in C++ using ActiveX — but that requires Internet Explorer on Windows on x86 hardware (so not Windows 8 RT) and is blocked by default security settings.

You can use any language you like for server side code, providing you can interface it with a webserver. CGI and FastCGI provide standard interfaces with supporting libraries for most languages.

Sign up to request clarification or add additional context in comments.

Comments

2

Yes, but you need to use a web framework like TreeFrog. TreeFrog is a full-stack web development framework, so you would be able to use C++ for both the front and back ends.

Comments

1

Yes, that will work as soon as you write your own browser that contains a C++ compiler (or parser). Please tell me which browser that is, so that I can make sure it never gets anywhere near any of my machines, since I definitely wouldn't want a full-fledged C++ program running on my machine - what's to say it's not got code in it that can do harm to my machine (delete files, write to registry, whatever)?

If you actually want your web-clients to have a private program of yours, you'd better distribute it in an already compiled executable or browser plugin [but beware that like me, many others probably won't download it unless you are part of a reputable organisation].

2 Comments

peterson So there's no way to have, lets say, an input box on a websitethat would function as the cin command in c++?
That's not quite what I said, you can't ship C++ code inside your web-page. I would suggest that you are asking an XY question, you have an idea that you'd like to do X, and to do so, you want to use Y mechanism, so you ask how to do Y. Now, in this case, it's almost certain that Y is the WRONG way. In general, it's better to ask a mechanic how to fix a puncture than how to loosen a wheelnut, since loosening a wheelnut is only PART of what you need to do.

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.