The prevalence of client-based web attacks, which exploit web vulnerabil- ities, has been increasing with the growth of web sites. Although pattern detection has been widely used to protect against web attacks, it has a high probability of failing to detect new types of attacks. To address this issue, we propose a novel approach for responding to three typical client- based web attacks (JavaScript malware, phishing attacks, and script- based web attacks) using machine learning algorithms. Our approach involves extracting relevant features from source code and URLs, and then training and testing various machine learning models (including Random Forest, Deep Neural Network, and Convolutional Neural Net- work) to determine the final model. Our experimental results indicate that our Random Forest model achieved high accuracy rates, with 99.99% for JavaScript malware, 95.11% for phishing attacks, and 94.77% for script-based web attacks. Furthermore, we developed a Chrome extension that uses the learned models to block client-based web attacks.